diff options
Diffstat (limited to 'sw/source/ui/shells')
30 files changed, 21149 insertions, 0 deletions
diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx new file mode 100755 index 000000000000..b7b7b509d036 --- /dev/null +++ b/sw/source/ui/shells/annotsh.cxx @@ -0,0 +1,1634 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> + +#include <tools/shl.hxx> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/i18n/TextConversionOption.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <sfx2/objface.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <editeng/spltitem.hxx> +#include <editeng/orphitem.hxx> +#include <editeng/brkitem.hxx> +#include <editeng/widwitem.hxx> +#include <editeng/kernitem.hxx> +#include <editeng/escpitem.hxx> +#include <editeng/lspcitem.hxx> +#include <editeng/adjitem.hxx> +#include <editeng/crsditem.hxx> +#include <editeng/shdditem.hxx> +#include <editeng/hyznitem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <svx/clipfmtitem.hxx> +#include <svl/stritem.hxx> +#include <svl/slstitm.hxx> +#include <editeng/colritem.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/cntritem.hxx> +#include <editeng/postitem.hxx> +#include <editeng/frmdiritem.hxx> +#include <svx/svdoutl.hxx> +#include <svl/whiter.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> +#include <unotools/useroptions.hxx> +#include <vcl/msgbox.hxx> +#include <editeng/flditem.hxx> +#include <editeng/editstat.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/htmlmode.hxx> +#include <editeng/langitem.hxx> +#include <editeng/unolingu.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/writingmodeitem.hxx> +#include <swundo.hxx> +#include <doc.hxx> +#include <viewopt.hxx> +#include <wrtsh.hxx> +#include <uitool.hxx> +#include <popup.hrc> +#include <pardlg.hxx> +#include <swdtflvr.hxx> +#include <drwtxtsh.hxx> +#include <swmodule.hxx> +#include <initui.hxx> +#include <edtwin.hxx> +#include <swwait.hxx> +#include <docstat.hxx> + +#include <cmdid.h> +#include <globals.hrc> +#include <shells.hrc> +#include <breakit.hxx> +#include "annotsh.hxx" +#include "view.hxx" +#include "PostItMgr.hxx" +#include "postit.hxx" + +#include "swtypes.hxx" + +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> + +#include <svx/svxids.hrc> +#include <svl/itempool.hxx> +#include <editeng/outliner.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editview.hxx> + +#include <svl/languageoptions.hxx> +#include <editeng/langitem.hxx> +#include <svtools/langtab.hxx> +#include <svl/slstitm.hxx> + +#include <docsh.hxx> +#include <svl/undo.hxx> +#include "swabstdlg.hxx" //CHINA001 +#include "chrdlg.hrc" //CHINA001 +#include "misc.hrc" +#include <app.hrc> + +#include <comphelper/processfactory.hxx> + +#include <cppuhelper/bootstrap.hxx> + +#include <langhelper.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::i18n; + +#define SwAnnotationShell + +#include <sfx2/msg.hxx> +#include <swslots.hxx> + +SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) +{ + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX)); + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU)); +} + +TYPEINIT1(SwAnnotationShell,SfxShell) + +SwAnnotationShell::SwAnnotationShell( SwView& r ) +: rView(r) +{ + SwWrtShell &rSh = rView.GetWrtShell(); + SetPool(rSh.GetAttrPool().GetSecondaryPool()); +} + +SwAnnotationShell::~SwAnnotationShell() +{ +} + +SfxUndoManager* SwAnnotationShell::GetUndoManager() +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + { + DBG_ASSERT(pPostItMgr,"PostItMgr::Layout(): We are looping forever"); + return 0; + } + return &pPostItMgr->GetActivePostIt()->Engine()->GetUndoManager(); +} + +void SwAnnotationShell::Exec( SfxRequest &rReq ) +{ + //TODO: clean this up!!!! + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); + + sal_uInt16 nSlot = rReq.GetSlot(); + sal_uInt16 nWhich = GetPool().GetWhich(nSlot); + const SfxItemSet *pNewAttrs = rReq.GetArgs(); + sal_uInt16 nEEWhich = 0; + switch (nSlot) + { + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_FONTHEIGHT: + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + { + SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool(); + if( !pSecondPool ) + pSecondPool = aEditAttr.GetPool(); + SvxScriptSetItem aSetItem( nSlot, *pSecondPool ); + aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich )); + aNewAttr.Put( aSetItem.GetItemSet() ); + rReq.Done(); + break; + } + case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; + case SID_ATTR_CHAR_UNDERLINE: + { + FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); + aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE)); + break; + } + case SID_ATTR_CHAR_OVERLINE: + { + FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle(); + aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE)); + break; + } + case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; + case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break; + case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break; + case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break; + case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break; + case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; + case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break; + case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break; + case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break; + case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break; + case SID_ATTR_PARA_ADJUST_LEFT: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST)); + break; + case SID_ATTR_PARA_ADJUST_CENTER: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST)); + break; + case SID_ATTR_PARA_ADJUST_RIGHT: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST)); + break; + case SID_ATTR_PARA_ADJUST_BLOCK: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST)); + break; + + case SID_ATTR_PARA_LINESPACE_10: + { + SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL); + aItem.SetPropLineSpace(100); + aNewAttr.Put(aItem); + } + break; + case SID_ATTR_PARA_LINESPACE_15: + { + SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL); + aItem.SetPropLineSpace(150); + aNewAttr.Put(aItem); + } + break; + case SID_ATTR_PARA_LINESPACE_20: + { + SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL); + aItem.SetPropLineSpace(200); + aNewAttr.Put(aItem); + } + break; + case SID_SELECTALL: + { + Outliner * pOutliner = pOLV->GetOutliner(); + if(pOutliner) + { + ULONG nParaCount = pOutliner->GetParagraphCount(); + if (nParaCount > 0) + pOLV->SelectRange(0L, USHORT(nParaCount) ); + } + break; + } + case FN_FORMAT_RESET: + { + pPostItMgr->GetActivePostIt()->ResetAttributes(); + rReq.Done(); + break; + } + case FN_SET_SUPER_SCRIPT: + { + SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); + SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) + aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + + if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) + aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); + else + aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); + aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); + } + break; + case FN_SET_SUB_SCRIPT: + { + SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); + SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) + aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + + if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) + aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); + else + aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); + aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); + } + break; + case SID_HYPERLINK_SETLINK: + { + const SfxPoolItem* pItem = 0; + if(pNewAttrs) + pNewAttrs->GetItemState(nSlot, sal_False, &pItem); + + if(pItem) + { + const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; + SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT); + aFld.SetTargetFrame(rHLinkItem.GetTargetFrame()); + + const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); + + if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField)) + { + // Feld selektieren, so dass es beim Insert geloescht wird + ESelection aSel = pOLV->GetSelection(); + aSel.nEndPos++; + pOLV->SetSelection(aSel); + } + if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) + pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD)); + } + break; + } + case FN_INSERT_SOFT_HYPHEN: + case FN_INSERT_HARDHYPHEN: + case FN_INSERT_HARD_SPACE: + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + sal_Unicode cIns = 0; + switch(rReq.GetSlot()) + { + case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; + case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break; + case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break; + case SID_INSERT_RLM : cIns = CHAR_RLM ; break; + case SID_INSERT_LRM : cIns = CHAR_LRM ; break; + case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; + case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; + } + pOLV->InsertText( String(cIns)); + rReq.Done(); + break; + } + case SID_CHARMAP: + { + if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) + InsertSymbol(rReq); + break; + } + case FN_INSERT_STRING: + { + const SfxPoolItem* pItem = 0; + if(pNewAttrs) + pNewAttrs->GetItemState(nSlot, FALSE, &pItem ); + if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) + pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue()); + break; + } + + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( rView.GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + rView.GetWindow(), &aTmp, rView.GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwWrtShell &rSh = rView.GetWrtShell(); + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *rView.GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; + case SID_CHAR_DLG: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + + if( !pArgs ) + { + /* mod + SwView* pView = &GetView(); + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric)); + */ + SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END); + + // util::Language gibts an der EditEngine nicht! Daher nicht im Set. + + aDlgAttr.Put( aEditAttr ); + aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) ); + + //CHINA001 SwCharDlg* pDlg = new SwCharDlg(pView->GetWindow(), *pView, aDlgAttr, 0, sal_True); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001 + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001 + + SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR,0, sal_True ); + DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 + USHORT nRet = pDlg->Execute(); + if(RET_OK == nRet ) + { + rReq.Done( *( pDlg->GetOutputItemSet() ) ); + aNewAttr.Put(*pDlg->GetOutputItemSet()); + } + delete( pDlg ); + if(RET_OK != nRet) + return ; + } + else + aNewAttr.Put(*pArgs); + break; + } + case SID_PARA_DLG: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + + if (!pArgs) + { + /* mod todo ??? + SwView* pView = &GetView(); + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric)); + */ + SfxItemSet aDlgAttr(GetPool(), + EE_ITEMS_START, EE_ITEMS_END, + SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE, + SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT, + SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS, + SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS, + 0); + + aDlgAttr.Put(aEditAttr); + + + aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) ); + aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) ); + aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) ); + aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) ); + aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) ); + + //CHINA001 SwParaDlg* pDlg = new SwParaDlg(GetView().GetWindow(), GetView(), aDlgAttr, DLG_STD, 0, sal_True); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001 + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001 + + SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True ); + DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 + USHORT nRet = pDlg->Execute(); + if(RET_OK == nRet) + { + rReq.Done( *( pDlg->GetOutputItemSet() ) ); + aNewAttr.Put(*pDlg->GetOutputItemSet()); + } + delete( pDlg ); + if(RET_OK != nRet) + return; + } + else + aNewAttr.Put(*pArgs); + break; + } + + case SID_AUTOSPELL_CHECK: + { + rView.ExecuteSlot(rReq); + break; + } + case SID_ATTR_PARA_LEFT_TO_RIGHT: + case SID_ATTR_PARA_RIGHT_TO_LEFT: + { + sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT; + + const SfxPoolItem* pPoolItem; + if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, TRUE, &pPoolItem ) ) + { + if( !( (SfxBoolItem*)pPoolItem)->GetValue() ) + bLeftToRight = !bLeftToRight; + } + SfxItemSet aAttr( *aNewAttr.GetPool(), + EE_PARA_JUST, EE_PARA_JUST, + EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, + 0 ); + + USHORT nAdjust = SVX_ADJUST_LEFT; + if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, TRUE, &pPoolItem ) ) + nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue(); + + if( bLeftToRight ) + { + aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); + if( nAdjust == SVX_ADJUST_RIGHT ) + aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); + } + else + { + aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) ); + if( nAdjust == SVX_ADJUST_LEFT ) + aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); + } + pOLV->SetAttribs(aAttr); + break; + } + } + + if(nEEWhich && pNewAttrs) + aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich); + + Rectangle aNullRect; + Rectangle aOutRect = pOLV->GetOutputArea(); + if (aNullRect != aOutRect) + pOLV->SetAttribs(aNewAttr); + + rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); + if ( pOLV->GetOutliner()->IsModified() ) + rView.GetWrtShell().SetModified(); + +} + +void SwAnnotationShell::GetState(SfxItemSet& rSet) +{ + //TODO: clean this up!!! + // FN_SET_SUPER_SCRIPT + //SID_ATTR_PARA_ADJUST + //SID_ATTR_PARA_ADJUST_BLOCK + + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + while(nWhich) + { + sal_uInt16 nEEWhich = 0; + USHORT nSlotId = GetPool().GetSlotId( nWhich ); + switch( nSlotId ) + { + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_FONTHEIGHT: + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + { + if ( pOLV ) + { + USHORT nScriptType = pOLV->GetSelectedScriptType(); + SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool(); + if( !pSecondPool ) + pSecondPool = aEditAttr.GetPool(); + SvxScriptSetItem aSetItem( nSlotId, *pSecondPool ); + aSetItem.GetItemSet().Put( aEditAttr, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); + if( pI ) + rSet.Put( *pI, nWhich ); + else + rSet.InvalidateItem( nWhich ); + } + else + rSet.InvalidateItem( nWhich ); + } + break; + case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; + case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break; + case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break; + case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; + case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break; + case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break; + case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; + case FN_SET_SUPER_SCRIPT: + case FN_SET_SUB_SCRIPT: + { + USHORT nEsc = 0; + const SfxPoolItem *pEscItem = 0; + if (nWhich==FN_SET_SUPER_SCRIPT) + nEsc = SVX_ESCAPEMENT_SUPERSCRIPT; + else + nEsc = SVX_ESCAPEMENT_SUBSCRIPT; + + if( !pEscItem ) + pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT ); + + if( nEsc == ((const SvxEscapementItem*)pEscItem)->GetEnumValue() ) + rSet.Put( SfxBoolItem( nWhich, sal_True )); + else + rSet.InvalidateItem( nWhich ); + break; + } + case SID_ATTR_PARA_ADJUST_LEFT: + case SID_ATTR_PARA_ADJUST_RIGHT: + case SID_ATTR_PARA_ADJUST_CENTER: + case SID_ATTR_PARA_ADJUST_BLOCK: + { + const SfxPoolItem *pAdjust = 0; + int eAdjust = 0; + + if (nWhich==SID_ATTR_PARA_ADJUST_LEFT) + eAdjust = SVX_ADJUST_LEFT; + else + if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT) + eAdjust = SVX_ADJUST_RIGHT; + else + if (nWhich==SID_ATTR_PARA_ADJUST_CENTER) + eAdjust = SVX_ADJUST_CENTER; + else + if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK) + eAdjust = SVX_ADJUST_BLOCK; + + if( !pAdjust ) + aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust); + + if( !pAdjust || IsInvalidItem( pAdjust )) + rSet.InvalidateItem( nSlotId ), nSlotId = 0; + else + { + if ( eAdjust == ((const SvxAdjustItem*)pAdjust)->GetAdjust()) + rSet.Put( SfxBoolItem( nWhich, sal_True )); + else + rSet.InvalidateItem( nWhich ); + } + break; + } + case SID_ATTR_PARA_LINESPACE_10: + case SID_ATTR_PARA_LINESPACE_15: + case SID_ATTR_PARA_LINESPACE_20: + { + const SfxPoolItem *pLSpace = 0; + int nLSpace = 0; + + if (nWhich==SID_ATTR_PARA_LINESPACE_10) + nLSpace = 100; + else + if (nWhich==SID_ATTR_PARA_LINESPACE_15) + nLSpace = 150; + else + if (nWhich==SID_ATTR_PARA_LINESPACE_20) + nLSpace = 200; + + if( !pLSpace ) + aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace ); + + if( !pLSpace || IsInvalidItem( pLSpace )) + rSet.InvalidateItem( nSlotId ), nSlotId = 0; + else + { + if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->GetPropLineSpace() ) + rSet.Put( SfxBoolItem( nWhich, sal_True )); + else + rSet.InvalidateItem( nWhich ); + } + break; + } + case SID_AUTOSPELL_CHECK: + { + const SfxPoolItem* pState = rView.GetSlotState(nWhich); + if (pState) + rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue())); + else + rSet.DisableItem( nWhich ); + break; + } + case SID_ATTR_PARA_LEFT_TO_RIGHT: + case SID_ATTR_PARA_RIGHT_TO_LEFT: + { + if ( !SvtLanguageOptions().IsCTLFontEnabled() ) + rSet.DisableItem( nWhich ); + else + { + if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical()) + rSet.DisableItem( nWhich ); + else + { + BOOL bFlag = FALSE; + switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() ) + { + case FRMDIR_HORI_LEFT_TOP: + { + bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT; + rSet.Put( SfxBoolItem( nWhich, bFlag )); + break; + } + case FRMDIR_HORI_RIGHT_TOP: + { + bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT; + rSet.Put( SfxBoolItem( nWhich, bFlag )); + break; + } + } + } + } + } + break; + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + SvtCTLOptions aCTLOptions; + sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); + rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); + if(!bEnabled) + rSet.DisableItem(nWhich); + } + break; + default: + rSet.InvalidateItem( nWhich ); + break; + } + + if(nEEWhich) + rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich); + + if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) + rSet.DisableItem( nWhich ); + + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::ExecSearch(SfxRequest& rReq, BOOL bNoMessage) +{ + rView.ExecSearch(rReq,bNoMessage); +} + +void SwAnnotationShell::StateSearch(SfxItemSet &rSet) +{ + rView.StateSearch(rSet); +} + +void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); + + long aOldHeight = pPostItMgr->GetActivePostIt()->GetPostItTextHeight(); + sal_uInt16 nSlot = rReq.GetSlot(); + switch (nSlot) + { + case SID_CUT: + if ( (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() ) + pOLV->Cut(); + break; + case SID_COPY: + if( pOLV->HasSelection() ) + pOLV->Copy(); + break; + case SID_PASTE: + if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) + pOLV->Paste(); + break; + case SID_PASTE_SPECIAL: + { + if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() ); + + pDlg->Insert( SOT_FORMAT_STRING, aEmptyStr ); + pDlg->Insert( SOT_FORMAT_RTF, aEmptyStr ); + + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) ); + + ULONG nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); + + if (nFormat > 0) + { + if (nFormat == SOT_FORMAT_STRING) + pOLV->Paste(); + else + pOLV->PasteSpecial(); + } + delete pDlg; + } + break; + } + case SID_CLIPBOARD_FORMAT_ITEMS: + { + ULONG nFormat = 0; + const SfxPoolItem* pItem; + if ( rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && + pItem->ISA(SfxUInt32Item) ) + { + nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); + } + + if ( nFormat ) + { + if (SOT_FORMAT_STRING == nFormat) + pOLV->Paste(); + else + pOLV->PasteSpecial(); + } + break; + } + } + pPostItMgr->GetActivePostIt()->ResizeIfNeccessary(aOldHeight,pPostItMgr->GetActivePostIt()->GetPostItTextHeight()); +} + +void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) ); + bool bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); + bPastePossible = bPastePossible && (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED); + + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while(nWhich) + { + switch(nWhich) + { + case SID_CUT: + { + if ( (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) || !pOLV->HasSelection() ) + rSet.DisableItem( nWhich ); + } + case SID_COPY: + { + if( !pOLV->HasSelection() ) + rSet.DisableItem( nWhich ); + break; + } + case SID_PASTE: + case SID_PASTE_SPECIAL: + { + if( !bPastePossible ) + rSet.DisableItem( nWhich ); + break; + } + case SID_CLIPBOARD_FORMAT_ITEMS: + { + if ( bPastePossible ) + { + SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); + if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) + aFormats.AddClipbrdFormat( SOT_FORMAT_RTF ); + //if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) + aFormats.AddClipbrdFormat( SOT_FORMAT_STRING ); + rSet.Put( aFormats ); + } + else + rSet.DisableItem( nWhich ); + break; + } + } + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet) +{ + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + while( nWhich ) + { + switch( nWhich ) + { + case FN_STAT_SELMODE: + { + rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0)); + rSet.DisableItem( nWhich ); + break; + } + case FN_STAT_TEMPLATE: + { + rSet.DisableItem( nWhich ); + break; + } + } + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::StateInsert(SfxItemSet &rSet) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while(nWhich) + { + switch(nWhich) + { + case SID_HYPERLINK_GETLINK: + { + SvxHyperlinkItem aHLinkItem; + aHLinkItem.SetInsertMode(HLINK_FIELD); + + const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); + + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + + if (pField->ISA(SvxURLField)) + { + aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation()); + aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL()); + aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame()); + } + } + else + { + String sSel(pOLV->GetSelected()); + sSel.Erase(255); + sSel.EraseTrailingChars(); + aHLinkItem.SetName(sSel); + } + + sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell()); + aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | + ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); + + rSet.Put(aHLinkItem); + } + break; + } + + if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) + rSet.DisableItem( nWhich ); + + nWhich = aIter.NextWhich(); + } +} + + +void SwAnnotationShell::NoteExec(SfxRequest &rReq) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr ) + return; + + sal_uInt16 nSlot = rReq.GetSlot(); + switch (nSlot) + { + case FN_REPLY: + case FN_POSTIT: + case FN_DELETE_COMMENT: + case FN_DELETE_NOTE: + if ( pPostItMgr->GetActivePostIt() ) + pPostItMgr->GetActivePostIt()->ExecuteCommand(nSlot); + break; + case FN_DELETE_ALL_NOTES: + pPostItMgr->Delete(); + break; + case FN_DELETE_NOTE_AUTHOR: + { + SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, FALSE); + if ( pItem ) + pPostItMgr->Delete( pItem->GetValue() ); + break; + } + case FN_HIDE_NOTE: + /* + if ( Mgr()->GetActivePostIt() == this ) + { + Mgr()->SetActivePostIt(0); + // put the cursor back into the document + SwitchToFieldPos(); + } + Mgr()->Hide(mpFld); + */ + break; + case FN_HIDE_ALL_NOTES: + pPostItMgr->Hide(); + break; + case FN_HIDE_NOTE_AUTHOR: + { + SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, FALSE); + if ( pItem ) + pPostItMgr->Hide( pItem->GetValue() ); + } + } +} + +void SwAnnotationShell::GetNoteState(SfxItemSet &rSet) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + while(nWhich) + { + USHORT nSlotId = GetPool().GetSlotId( nWhich ); + switch( nSlotId ) + { + case FN_POSTIT: + case FN_DELETE_NOTE: + case FN_DELETE_NOTE_AUTHOR: + case FN_DELETE_ALL_NOTES: + case FN_HIDE_NOTE: + case FN_HIDE_NOTE_AUTHOR: + case FN_HIDE_ALL_NOTES: + { + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() || !pPostItMgr->GetActivePostIt()->ISA(SwPostIt)) + rSet.DisableItem(nWhich); + break; + } + case FN_DELETE_COMMENT: + { + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) //|| !pPostItMgr->GetActivePostIt()->ISA(SwRedComment)) + rSet.DisableItem(nWhich); + break; + } + case FN_REPLY: + { + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() || !pPostItMgr->GetActivePostIt()->ISA(SwPostIt)) + rSet.DisableItem(nWhich); + else + { + SvtUserOptions aUserOpt; + String sAuthor; + if( !(sAuthor = aUserOpt.GetFullName()).Len()) + if( !(sAuthor = aUserOpt.GetID()).Len() ) + sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); + if (sAuthor == pPostItMgr->GetActivePostIt()->GetAuthor()) + rSet.DisableItem(nWhich); + } + break; + } + default: + rSet.InvalidateItem( nWhich ); + break; + } + + if (pPostItMgr->GetActivePostIt()) + { + if ( (pPostItMgr->GetActivePostIt()->IsProtected()) && + ( (nSlotId==FN_DELETE_NOTE) || (nSlotId==FN_REPLY) ) ) + rSet.DisableItem( nWhich ); + } + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::ExecLingu(SfxRequest &rReq) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + sal_uInt16 nSlot = rReq.GetSlot(); + SwWrtShell &rSh = rView.GetWrtShell(); + bool bRestoreSelection = false; + ESelection aOldSelection; + + switch (nSlot) + { + case SID_LANGUAGE_STATUS: + { + aOldSelection = pOLV->GetSelection(); + if (!pOLV->GetEditView().HasSelection()) + { + bRestoreSelection = true; + pOLV->GetEditView().SelectCurrentWord(); + } + + bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh); + break; + } + case FN_THESAURUS_DLG: + { + pOLV->StartThesaurus(); + break; + } + case SID_HANGUL_HANJA_CONVERSION: + pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, + i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False ); + break; + + case SID_CHINESE_CONVERSION: + { + //open ChineseTranslationDialog + Reference< XComponentContext > xContext( + ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one + if(xContext.is()) + { + Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); + if(xMCF.is()) + { + Reference< ui::dialogs::XExecutableDialog > xDialog( + xMCF->createInstanceWithContext( + rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog") + , xContext), UNO_QUERY); + Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); + if( xInit.is() ) + { + // initialize dialog + Reference< awt::XWindow > xDialogParentWindow(0); + Sequence<Any> aSeq(1); + Any* pArray = aSeq.getArray(); + PropertyValue aParam; + aParam.Name = rtl::OUString::createFromAscii("ParentWindow"); + aParam.Value <<= makeAny(xDialogParentWindow); + pArray[0] <<= makeAny(aParam); + xInit->initialize( aSeq ); + + //execute dialog + sal_Int16 nDialogRet = xDialog->execute(); + if( RET_OK == nDialogRet ) + { + //get some parameters from the dialog + sal_Bool bToSimplified = sal_True; + sal_Bool bUseVariants = sal_True; + sal_Bool bCommonTerms = sal_True; + Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); + if( xProp.is() ) + { + try + { + xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified; + xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants; + xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms; + } + catch( Exception& ) + { + } + } + + //execute translation + sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; + sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; + sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; + if( !bCommonTerms ) + nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; + + Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT, + nTargetLang, DEFAULTFONT_FLAGS_ONLYONE ); + + pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False ); + } + } + Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); + if( xComponent.is() ) + xComponent->dispose(); + } + } + } + break; + } + + if (bRestoreSelection) + { + // restore selection + pOLV->GetEditView().SetSelection( aOldSelection ); + } +} + +void SwAnnotationShell::GetLinguState(SfxItemSet &rSet) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + while(nWhich) + { + switch (nWhich) + { + case SID_LANGUAGE_STATUS: + { + SwLangHelper::GetLanguageStatus(pOLV,rSet); + break; + } + // disable "Thesaurus" if the language is not supported + case FN_THESAURUS_DLG: + { + const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault( + GetWhichOfScript( RES_CHRATR_LANGUAGE, + GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage())) ); + LanguageType nLang = ((const SvxLanguageItem &) + rItem).GetLanguage(); + uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); + if (!xThes.is() || nLang == LANGUAGE_NONE || + !xThes->hasLocale( SvxCreateLocale( nLang ) )) + rSet.DisableItem( FN_THESAURUS_DLG ); + } + break; + case SID_HANGUL_HANJA_CONVERSION: + case SID_CHINESE_CONVERSION: + { + if (!SvtCJKOptions().IsAnyEnabled()) + { + rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); + rSet.DisableItem(nWhich); + } + else + rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); + } + break; + } + + if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) + rSet.DisableItem( nWhich ); + + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + + using namespace ::com::sun::star::i18n; + { + sal_uInt32 nMode = 0; + + switch( rReq.GetSlot() ) + { + case SID_TRANSLITERATE_UPPER: + nMode = TransliterationModules_LOWERCASE_UPPERCASE; + break; + case SID_TRANSLITERATE_LOWER: + nMode = TransliterationModules_UPPERCASE_LOWERCASE; + break; + case SID_TRANSLITERATE_HALFWIDTH: + nMode = TransliterationModules_FULLWIDTH_HALFWIDTH; + break; + case SID_TRANSLITERATE_FULLWIDTH: + nMode = TransliterationModules_HALFWIDTH_FULLWIDTH; + break; + case SID_TRANSLITERATE_HIRAGANA: + nMode = TransliterationModules_KATAKANA_HIRAGANA; + break; + case SID_TRANSLITERATE_KATAGANA: + nMode = TransliterationModules_HIRAGANA_KATAKANA; + break; + + default: + ASSERT(!this, "falscher Dispatcher"); + } + + if( nMode ) + { + pOLV->TransliterateText( nMode ); + } + } +} + +void SwAnnotationShell::ExecUndo(SfxRequest &rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + SfxUndoManager* pUndoManager = GetUndoManager(); + SwWrtShell &rSh = rView.GetWrtShell(); + + long aOldHeight = rView.GetPostItMgr()->GetActivePostIt() ? rView.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight() : 0; + + USHORT nId = rReq.GetSlot(); + sal_uInt16 nCnt = 1; + const SfxPoolItem* pItem=0; + if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem ) ) + nCnt = ((SfxUInt16Item*)pItem)->GetValue(); + switch( nId ) + { + case SID_UNDO: + { + if ( pUndoManager ) + { + sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); + sal_uInt16 nSteps = nCnt; + if ( nCount < nCnt ) + { + nCnt = nCnt - nCount; + nSteps = nCount; + } + else + nCnt = 0; + + while( nSteps-- ) + pUndoManager->Undo(0); + } + + if ( nCnt ) + rSh.Do( SwWrtShell::UNDO, nCnt ); + + break; + } + + case SID_REDO: + { + if ( pUndoManager ) + { + sal_uInt16 nCount = pUndoManager->GetRedoActionCount(); + sal_uInt16 nSteps = nCnt; + if ( nCount < nCnt ) + { + nCnt = nCnt - nCount; + nSteps = nCount; + } + else + nCnt = 0; + + while( nSteps-- ) + pUndoManager->Redo(0); + } + + if ( nCnt ) + rSh.Do( SwWrtShell::REDO, nCnt ); + + break; + } + } + + rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); + + if (rView.GetPostItMgr()->GetActivePostIt()) + rView.GetPostItMgr()->GetActivePostIt()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight()); +} + +void SwAnnotationShell::StateUndo(SfxItemSet &rSet) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + SfxUndoManager* pUndoManager = GetUndoManager(); + SfxViewFrame *pSfxViewFrame = rView.GetViewFrame(); + SwWrtShell &rSh = rView.GetWrtShell(); + + while( nWhich ) + { + switch ( nWhich ) + { + case SID_UNDO: + { + sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); + if ( nCount ) + pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); + else if( rSh.GetUndoIds() ) + rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) ); + else + rSet.DisableItem(nWhich); + break; + } + case SID_REDO: + { + sal_uInt16 nCount = pUndoManager->GetRedoActionCount(); + if ( nCount ) + pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); + else if(rSh.GetRedoIds()) + rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) ); + else + rSet.DisableItem(nWhich); + break; + } + case SID_GETUNDOSTRINGS: + case SID_GETREDOSTRINGS: + { + if( pUndoManager ) + { + UniString (SfxUndoManager:: *fnGetComment)( USHORT ) const; + + sal_uInt16 nCount; + if( SID_GETUNDOSTRINGS == nWhich ) + { + nCount = pUndoManager->GetUndoActionCount(); + fnGetComment = &SfxUndoManager::GetUndoActionComment; + } + else + { + nCount = pUndoManager->GetRedoActionCount(); + fnGetComment = &SfxUndoManager::GetRedoActionComment; + } + + String sList; + if( nCount ) + { + for( sal_uInt16 n = 0; n < nCount; ++n ) + ( sList += (pUndoManager->*fnGetComment)( n ) ) + += '\n'; + } + + SfxStringListItem aItem( nWhich ); + if( nWhich == SID_GETUNDOSTRINGS && rSh.GetUndoIds() ) + { + rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); + } + else if( nWhich == SID_GETREDOSTRINGS && rSh.GetRedoIds() ) + { + rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); + } + + sList += aItem.GetString(); + aItem.SetString( sList ); + rSet.Put( aItem ); + } + else + rSet.DisableItem( nWhich ); + } + break; + + default: + { + pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); + break; + } + + } + + if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) + rSet.DisableItem( nWhich ); + + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet ) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + +void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) +{ + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) + return; + + OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View(); + + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + if( pArgs ) + pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem); + + String sSym; + String sFontName; + if ( pItem ) + { + sSym = ((const SfxStringItem*)pItem)->GetValue(); + const SfxPoolItem* pFtItem = NULL; + pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem); + const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); + if ( pFontItem ) + sFontName = pFontItem->GetValue(); + } + + SfxItemSet aSet(pOLV->GetAttribs()); + USHORT nScript = pOLV->GetSelectedScriptType(); + SvxFontItem aSetDlgFont( RES_CHRATR_FONT ); + { + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); + aSetItem.GetItemSet().Put( aSet, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); + if( pI ) + aSetDlgFont = *(SvxFontItem*)pI; + else + aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( + SID_ATTR_CHAR_FONT, + GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) )); + if (!sFontName.Len()) + sFontName = aSetDlgFont.GetFamilyName(); + } + + Font aFont(sFontName, Size(1,1)); + if( !sSym.Len() ) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + + SfxAllItemSet aAllSet( GetPool() ); + aAllSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) ); + + SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions()); + String sSymbolFont = aOpt.GetSymbolFont(); + if( sSymbolFont.Len() ) + aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); + else + aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) ); + + // Wenn Zeichen selektiert ist kann es angezeigt werden + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet, + rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); + + USHORT nResult = pDlg->Execute(); + if( nResult == RET_OK ) + { + SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, FALSE ); + SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE ); + if ( pFontItem ) + { + aFont.SetName( pFontItem->GetFamilyName() ); + aFont.SetStyleName( pFontItem->GetStyleName() ); + aFont.SetCharSet( pFontItem->GetCharSet() ); + aFont.SetPitch( pFontItem->GetPitch() ); + } + + if ( pCItem ) + { + sSym = pCItem->GetValue(); + aOpt.SetSymbolFont(aFont.GetName()); + SW_MOD()->ApplyUsrPref(aOpt, &rView); + } + } + + delete( pDlg ); + } + + if( sSym.Len() ) + { + // nicht flackern + pOLV->HideCursor(); + Outliner * pOutliner = pOLV->GetOutliner(); + pOutliner->SetUpdateMode(FALSE); + + SfxItemSet aOldSet( pOLV->GetAttribs() ); + SfxItemSet aFontSet( *aOldSet.GetPool(), + EE_CHAR_FONTINFO, EE_CHAR_FONTINFO, + EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK, + EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL, + 0 ); + aFontSet.Set( aOldSet ); + + // String einfuegen + pOLV->InsertText( sSym); + + // attributieren (Font setzen) + SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() ); + SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(), + aFont.GetStyleName(), aFont.GetPitch(), + aFont.GetCharSet(), + EE_CHAR_FONTINFO ); + USHORT nScriptBreak = pBreakIt->GetAllScriptsOfText( sSym ); + if( SCRIPTTYPE_LATIN & nScriptBreak ) + aSetFont.Put( aFontItem, EE_CHAR_FONTINFO ); + if( SCRIPTTYPE_ASIAN & nScriptBreak ) + aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK ); + if( SCRIPTTYPE_COMPLEX & nScriptBreak ) + aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL ); + pOLV->SetAttribs(aSetFont); + + // Selektion loeschen + ESelection aSel(pOLV->GetSelection()); + aSel.nStartPara = aSel.nEndPara; + aSel.nStartPos = aSel.nEndPos; + pOLV->SetSelection(aSel); + + // Alten Font restaurieren + pOLV->SetAttribs( aFontSet ); + + // ab jetzt wieder anzeigen + pOutliner->SetUpdateMode(TRUE); + pOLV->ShowCursor(); + + rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) ); + if(aFont.GetName().Len()) + rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) ); + rReq.Done(); + } +} diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx new file mode 100644 index 000000000000..0cee102729a7 --- /dev/null +++ b/sw/source/ui/shells/basesh.cxx @@ -0,0 +1,2932 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <sot/factory.hxx> +#include <hintids.hxx> +#include <svl/urihelper.hxx> +#include <svl/languageoptions.hxx> + +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#include <sfx2/linkmgr.hxx> +#include <svx/htmlmode.hxx> +#include <svx/imapdlg.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/request.hxx> +#include <svl/whiter.hxx> +#include <svl/visitem.hxx> +#include <sfx2/objitem.hxx> +#include <svtools/filter.hxx> +#include <svx/gallery.hxx> +#include <editeng/langitem.hxx> +#include <svx/clipfmtitem.hxx> +#include <svx/contdlg.hxx> +#include <vcl/graph.hxx> +#include <svl/slstitm.hxx> +#include <vcl/msgbox.hxx> +#include <svl/ptitem.hxx> +#include <svl/itemiter.hxx> +#include <svl/stritem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/shaditem.hxx> +#include <editeng/boxitem.hxx> +#include <svl/srchitem.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/brshitem.hxx> +#include <editeng/opaqitem.hxx> +#include <editeng/sizeitem.hxx> +#include <svx/flagsdef.hxx> +#include <editeng/scripttypeitem.hxx> +#include <sfx2/objface.hxx> +#include <fmturl.hxx> +#include <fmthdft.hxx> +#include <fmtclds.hxx> +#include <docsh.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <swmodule.hxx> +#include <swundo.hxx> +#include <fldbas.hxx> +#include <uitool.hxx> +#include <basesh.hxx> +#include <viewopt.hxx> +#include <fontcfg.hxx> +#include <docstat.hxx> +#include <usrfld.hxx> +#include <expfld.hxx> +#include <fldmgr.hxx> +#include <frmmgr.hxx> +#include <tablemgr.hxx> +#include <mdiexp.hxx> +#include <swdtflvr.hxx> +#include <pagedesc.hxx> +#include <convert.hxx> +#include <fmtcol.hxx> +#include <edtwin.hxx> +#include <tblafmt.hxx> +#include <caption.hxx> +#include <swwait.hxx> +#include <cmdid.h> +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif +#ifndef _STATSTR_HRC +#include <statstr.hrc> +#endif +#include <globals.h> +#include <unotxdoc.hxx> +#include <crsskip.hxx> +#include <fmtinfmt.hxx> +#include <doc.hxx> + +#include "swabstdlg.hxx" +#include "dialog.hrc" +#include "fldui.hrc" +#include "table.hrc" +#include <modcfg.hxx> +#include <instable.hxx> +#include <svx/fmshell.hxx> // for FN_XFORMS_DESIGN_MODE +#include <SwRewriter.hxx> +#include <undobj.hxx> +#ifndef _COMCORE_HRC +#include <comcore.hrc> +#endif + +#include <unomid.h> + +FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END; + + +//Fuer die Erkennung der Id, die variable von Gallery mit SID_GALLERY_BG_BRUSH +//ankommt. +static BYTE nParagraphPos; +static BYTE nGraphicPos; +static BYTE nOlePos; +static BYTE nFramePos; +static BYTE nTablePos; +static BYTE nTableRowPos; +static BYTE nTableCellPos; +static BYTE nPagePos; +static BYTE nHeaderPos; +static BYTE nFooterPos; + +#define Interior +#include <svx/svxslots.hxx> + +#define SwBaseShell +#define Shadow +#include <sfx2/msg.hxx> +#include "swslots.hxx" + +#define SWCONTOURDLG(rView) ( (SvxContourDlg*) ( rView.GetViewFrame()->GetChildWindow( \ + SvxContourDlgChildWindow::GetChildWindowId() )-> \ + GetWindow() ) ) + +#define SWIMAPDLG(rView) ( (SvxIMapDlg*) ( rView.GetViewFrame()->GetChildWindow( \ + SvxIMapDlgChildWindow::GetChildWindowId() )-> \ + GetWindow() ) ) + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::lang; + + +SFX_IMPL_INTERFACE(SwBaseShell, SfxShell, SW_RES(0)) +{ + SFX_CHILDWINDOW_REGISTRATION(SvxIMapDlgChildWindow::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(SvxContourDlgChildWindow::GetChildWindowId()); +} + +TYPEINIT1(SwBaseShell,SfxShell) + +/*-------------------------------------------------------------------- + Beschreibung: statics + --------------------------------------------------------------------*/ + + +void lcl_UpdateIMapDlg( SwWrtShell& rSh ) +{ + Graphic aGrf( rSh.GetIMapGraphic() ); + GraphicType nGrfType = aGrf.GetType(); + void* pEditObj = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType + ? rSh.GetIMapInventor() : 0; + TargetList* pList = new TargetList; + rSh.GetView().GetViewFrame()->GetTopFrame().GetTargetList(*pList); + + SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); + rSh.GetFlyFrmAttr( aSet ); + const SwFmtURL &rURL = (SwFmtURL&)aSet.Get( RES_URL ); + SvxIMapDlgChildWindow::UpdateIMapDlg( + aGrf, rURL.GetMap(), pList, pEditObj ); + + USHORT nCount = (USHORT)pList->Count(); + if(nCount) + for( USHORT i = nCount; i; i-- ) + { + delete pList->GetObject(i-1); + } + delete pList; +} + + +BOOL lcl_UpdateContourDlg( SwWrtShell &rSh, int nSel ) +{ + Graphic aGraf( rSh.GetIMapGraphic() ); + GraphicType nGrfType = aGraf.GetType(); + BOOL bRet = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType; + if( bRet ) + { + String aGrfName; + if ( nSel & nsSelectionType::SEL_GRF ) + rSh.GetGrfNms( &aGrfName, 0 ); + + SvxContourDlg *pDlg = SWCONTOURDLG(rSh.GetView()); + pDlg->Update( aGraf, aGrfName.Len() > 0, + rSh.GetGraphicPolygon(), rSh.GetIMapInventor() ); + } + return bRet; +} + +/*-------------------------------------------------------------------- + Beschreibung: loeschen + --------------------------------------------------------------------*/ + +void SwBaseShell::ExecDelete(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + SwEditWin& rTmpEditWin = GetView().GetEditWin(); + switch(rReq.GetSlot()) + { + case SID_DELETE: + rSh.DelRight(); + break; + + case FN_BACKSPACE: + + if( rSh.IsNoNum() ) + { + rSh.SttCrsrMove(); + BOOL bLeft = rSh.Left( CRSR_SKIP_CHARS, TRUE, 1, FALSE ); + if( bLeft ) + { + // JP 28.03.96: ein Backspace im Absatz ohne Nummer wird zum Delete + //rSh.SwapPam(); + //rSh.DelRight( FALSE ); + + rSh.DelLeft(); + } + else + // JP 15.07.96: wenns nicht mehr nach vorne geht, die + // Numerierung aufheben. Z.B. am Doc-/ + // Rahmen-/Tabellen-/Bereichs-Anfang + rSh.DelNumRules(); + + rSh.EndCrsrMove(); + break; + } + + // ansonsten DelLeft rufen + case FN_SHIFT_BACKSPACE: + rSh.DelLeft(); + break; + default: + DBG_ERROR("falscher Dispatcher"); + return; + } + rReq.Done(); + + //#i42732# - notify the edit window that from now on we do not use the input language + rTmpEditWin.SetUseInputLanguage( sal_False ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwBaseShell::ExecClpbrd(SfxRequest &rReq) +{ + //Achtung: Suizid gefaehrdet! Nach Paste, Paste special kann der die + //Shell zerstoert sein. + + + SwWrtShell &rSh = GetShell(); + USHORT nId = rReq.GetSlot(); + sal_Bool bIgnore = sal_False; + switch( nId ) + { + case SID_CUT: + case SID_COPY: + rView.GetEditWin().FlushInBuffer(); + if ( rSh.HasSelection() ) + { + SwTransferable* pTransfer = new SwTransferable( rSh ); +/*??*/ uno::Reference< datatransfer::XTransferable > xRef( pTransfer ); + + if ( nId == SID_CUT && !rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT) ) + pTransfer->Cut(); + else + { + const BOOL bLockedView = rSh.IsViewLocked(); + rSh.LockView( TRUE ); //lock visible section + pTransfer->Copy(); + rSh.LockView( bLockedView ); + } + break; + } + return; + + case SID_PASTE: + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &rSh.GetView().GetEditWin() ) ); + + if( aDataHelper.GetXTransferable().is() && + SwTransferable::IsPaste( rSh, aDataHelper )) + { + // temp. Variablen, da die Shell nach dem Paste schon + // zerstoert sein kann + SwView* pView = &rView; + SwTransferable::Paste( rSh, aDataHelper ); + if( rSh.IsFrmSelected() || rSh.IsObjSelected() ) + rSh.EnterSelFrmMode(); + pView->AttrChangedNotify( &rSh ); + } + else + return; + } + break; + + case SID_CLIPBOARD_FORMAT_ITEMS: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + const SfxPoolItem* pFmt; + if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pFmt ) ) + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &rSh.GetView().GetEditWin()) ); + if( aDataHelper.GetXTransferable().is() + /*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ ) + { + // temp. Variablen, da die Shell nach dem Paste schon + // zerstoert sein kann + SwView* pView = &rView; + + SwTransferable::PasteFormat( rSh, aDataHelper, + ((SfxUInt32Item*)pFmt)->GetValue() ); + + //Done() has to be called before the shell has been removed + rReq.Done(); + bIgnore = sal_True; + if( rSh.IsFrmSelected() || rSh.IsObjSelected()) + rSh.EnterSelFrmMode(); + pView->AttrChangedNotify( &rSh ); + } + } + } + break; + + case SID_PASTE_UNFORMATTED: + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &rSh.GetView().GetEditWin()) ); + if( aDataHelper.GetXTransferable().is() && + SwTransferable::IsPaste( rSh, aDataHelper )) + { + // temp. Variablen, da die Shell nach dem Paste schon + // zerstoert sein kann + SwView* pView = &rView; + rReq.Ignore(); + bIgnore = sal_True; + int nRet = SwTransferable::PasteUnformatted( rSh, aDataHelper ); + if(nRet)// && rReq.IsRecording() ) + { + SfxViewFrame* pViewFrame = pView->GetViewFrame(); + uno::Reference< frame::XDispatchRecorder > xRecorder = + pViewFrame->GetBindings().GetRecorder(); + if(xRecorder.is()) { + SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS ); + aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, SOT_FORMAT_STRING ) ); + aReq.Done(); + } + } + + if (rSh.IsFrmSelected() || rSh.IsObjSelected()) + rSh.EnterSelFrmMode(); + pView->AttrChangedNotify( &rSh ); + } + else + return; + } + break; + + case SID_PASTE_SPECIAL: + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &rSh.GetView().GetEditWin()) ); + if( aDataHelper.GetXTransferable().is() && + SwTransferable::IsPaste( rSh, aDataHelper )) + { + // temp. Variablen, da die Shell nach dem Paste schon + // zerstoert sein kann + SwView* pView = &rView; + ULONG nFormatId = 0; + rReq.Ignore(); + bIgnore = sal_True; + int nRet = SwTransferable::PasteSpecial( rSh, aDataHelper, nFormatId ); + if(nRet)// && rReq.IsRecording() ) + { + SfxViewFrame* pViewFrame = pView->GetViewFrame(); + uno::Reference< frame::XDispatchRecorder > xRecorder = + pViewFrame->GetBindings().GetRecorder(); + if(xRecorder.is()) { + SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS ); + aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, nFormatId ) ); + aReq.Done(); + } + } + + if (rSh.IsFrmSelected() || rSh.IsObjSelected()) + rSh.EnterSelFrmMode(); + pView->AttrChangedNotify( &rSh ); + } + else + return; + } + break; + default: + DBG_ERROR("falscher Dispatcher"); + return; + } + if(!bIgnore) + rReq.Done(); +} + +/*-------------------------------------------------------------------- + Beschreibung: ClipBoard-Status + --------------------------------------------------------------------*/ + +void SwBaseShell::StateClpbrd(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + SfxWhichIter aIter(rSet); + + const BOOL bCopy = rSh.HasSelection(); + + USHORT nWhich = aIter.FirstWhich(); + + while(nWhich) + { + switch(nWhich) + { + case SID_CUT: + if( 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) ) + { + rSet.DisableItem( nWhich ); + break; + } + case SID_COPY: + if( !bCopy ) + rSet.DisableItem( nWhich ); + break; + + case SID_PASTE: + if( !GetView().IsPasteAllowed() ) + rSet.DisableItem( SID_PASTE ); + break; + + case SID_PASTE_SPECIAL: + if( !GetView().IsPasteSpecialAllowed() ) + { + rSet.DisableItem( SID_PASTE_SPECIAL ); + rSet.DisableItem( SID_PASTE_UNFORMATTED ); + } + break; + + case SID_CLIPBOARD_FORMAT_ITEMS: + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &rSh.GetView().GetEditWin()) ); + + SvxClipboardFmtItem aFmtItem( nWhich ); + SwTransferable::FillClipFmtItem( rSh, aDataHelper, aFmtItem ); + rSet.Put( aFmtItem ); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Undo ausfuehren + --------------------------------------------------------------------*/ + +void SwBaseShell::ExecUndo(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + + USHORT nId = rReq.GetSlot(), nCnt = 1; + const SfxItemSet* pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem )) + nCnt = ((SfxUInt16Item*)pItem)->GetValue(); + + // #i106349#: save pointer: undo/redo may delete the shell, i.e., this! + SfxViewFrame *const pViewFrame( GetView().GetViewFrame() ); + + switch( nId ) + { + case SID_UNDO: + rSh.LockPaint(); + rSh.Do( SwWrtShell::UNDO, nCnt ); + rSh.UnlockPaint(); + break; + + case SID_REDO: + rSh.LockPaint(); + rSh.Do( SwWrtShell::REDO, nCnt ); + rSh.UnlockPaint(); + break; + + case SID_REPEAT: + rSh.Do( SwWrtShell::REPEAT ); + break; + default: + DBG_ERROR("falscher Dispatcher"); + } + + if (pViewFrame) { pViewFrame->GetBindings().InvalidateAll(sal_False); } +} + +/*-------------------------------------------------------------------- + Beschreibung: Zustand Undo + --------------------------------------------------------------------*/ + +void SwBaseShell::StateUndo(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while(nWhich) + { + switch(nWhich) + { + case SID_UNDO: + { + if( rSh.GetUndoIds() ) + rSet.Put( SfxStringItem(nWhich, + rSh.GetDoString(SwWrtShell::UNDO))); + else + rSet.DisableItem(nWhich); + break; + } + case SID_REDO: + { + if(rSh.GetRedoIds()) + rSet.Put(SfxStringItem(nWhich, + rSh.GetDoString(SwWrtShell::REDO))); + else + rSet.DisableItem(nWhich); + break; + } + case SID_REPEAT: + { // Repeat nur moeglich wenn kein REDO moeglich - UI-Restriktion + if(rSh.GetRedoIds() == UNDO_EMPTY && + !rSh.IsSelFrmMode() && + rSh.GetRepeatIds() ) + rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString())); + else + rSet.DisableItem(nWhich); + break; + } + + case SID_GETUNDOSTRINGS: + if( rSh.GetUndoIds() ) + { + SfxStringListItem aStrLst( nWhich ); + rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst ); + rSet.Put( aStrLst ); + } + else + rSet.DisableItem( nWhich ); + break; + + case SID_GETREDOSTRINGS: + if( rSh.GetRedoIds() ) + { + SfxStringListItem aStrLst( nWhich ); + rSh.GetDoStrings( SwWrtShell::REDO, aStrLst ); + rSet.Put( aStrLst ); + } + else + rSet.DisableItem( nWhich ); + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Slot-Id auswerten bzw. Dispatchen + --------------------------------------------------------------------*/ + +void SwBaseShell::Execute(SfxRequest &rReq) +{ + const SfxPoolItem *pItem; + SwWrtShell &rSh = GetShell(); + const SfxItemSet* pArgs = rReq.GetArgs(); + BOOL bMore = FALSE; + + USHORT nSlot = rReq.GetSlot(); + switch(nSlot) + { + case FN_REPAGINATE: + { + Reference < XModel > xModel = GetView().GetDocShell()->GetModel(); + Reference < XUnoTunnel > xDocTunnel ( xModel, UNO_QUERY ); + SwXTextDocument *pDoc = reinterpret_cast < SwXTextDocument * > ( xDocTunnel->getSomething ( SwXTextDocument::getUnoTunnelId() ) ); + pDoc->notifyRefreshListeners(); + rSh.CalcLayout(); + } + break; + case FN_UPDATE_FIELDS: + { + SwDocStat aDocStat; + rSh.UpdateDocStat(aDocStat); + rSh.EndAllTblBoxEdit(); + rSh.ViewShell::UpdateFlds(TRUE); + + if( rSh.IsCrsrInTbl() ) + { + if( !rSh.IsTblComplexForChart() ) + SwTableFUNC( &rSh, FALSE).UpdateChart(); + rSh.ClearTblBoxCntnt(); + rSh.SaveTblBoxCntnt(); + } + } + break; + case FN_UPDATE_CHARTS: + { + SwWait aWait( *rView.GetDocShell(), TRUE ); + rSh.UpdateAllCharts(); + } + break; + + case FN_UPDATE_ALL: + { + SwView& rTempView = GetView(); + rSh.EnterStdMode(); + if( rSh.GetLinkManager().GetLinks().Count() ) + { + rSh.StartAllAction(); + rSh.GetLinkManager().UpdateAllLinks( FALSE, TRUE, TRUE ); + rSh.EndAllAction(); + } + SfxDispatcher &rDis = *rTempView.GetViewFrame()->GetDispatcher(); + rDis.Execute( FN_UPDATE_FIELDS ); + rDis.Execute( FN_UPDATE_TOX ); + rDis.Execute( FN_UPDATE_CHARTS ); + rSh.CalcLayout(); + } + break; + + case FN_UPDATE_INPUTFIELDS: + rSh.UpdateInputFlds(NULL, FALSE); + break; + case FN_PREV_BOOKMARK: + rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoPrevBookmark())); + break; + case FN_NEXT_BOOKMARK: + rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoNextBookmark())); + break; + + case FN_GOTO_NEXT_MARK: + case FN_GOTO_PREV_MARK: + { + SwFldMgr aFldMgr; + SwFieldType* pFldType = aFldMgr.GetFldType(RES_JUMPEDITFLD); + + if (pFldType) + { + if (rSh.IsSelFrmMode()) + { + rSh.UnSelectFrm(); + rSh.LeaveSelFrmMode(); + } + + if (rSh.HasMark()) + { + MV_KONTEXT(&rSh); + if (rSh.IsCrsrPtAtEnd()) + rSh.SwapPam(); + rSh.ClearMark(); + rSh.EndSelect(); + } + BOOL bRet = rSh.MoveFldType(pFldType, nSlot == FN_GOTO_NEXT_MARK); + if (bRet) + rSh.ClickToField(*rSh.GetCurFld()); + rReq.SetReturnValue(SfxBoolItem( nSlot, bRet)); + } + } + break; + + case FN_START_DOC_DIRECT: + case FN_END_DOC_DIRECT: + { + if (rSh.IsSelFrmMode()) + { + rSh.UnSelectFrm(); + rSh.LeaveSelFrmMode(); + } + rSh.EnterStdMode(); + nSlot == FN_START_DOC_DIRECT ? + rSh.SttEndDoc(TRUE) : + rSh.SttEndDoc(FALSE); + } + break; + case FN_GOTO_PREV_OBJ: + case FN_GOTO_NEXT_OBJ: + { + BOOL bSuccess = rSh.GotoObj( + nSlot == FN_GOTO_NEXT_OBJ ? TRUE : FALSE); + rReq.SetReturnValue(SfxBoolItem(nSlot, bSuccess)); + if (bSuccess && !rSh.IsSelFrmMode()) + { + rSh.HideCrsr(); + rSh.EnterSelFrmMode(); + GetView().AttrChangedNotify( &rSh ); + } + } + break; + case SID_GALLERY_FORMATS: + { + const int nSelType = rSh.GetSelectionType(); + if(SFX_ITEM_SET == pArgs->GetItemState( nSlot, TRUE, &pItem)) + { + GalleryExplorer* pGal = 0; + if ( (!rSh.IsSelFrmMode() || nSelType & nsSelectionType::SEL_GRF) && + 0!= (pGal = SVX_GALLERY())&& + 0 != (SGA_FORMAT_GRAPHIC & ((SfxUInt32Item*)pItem)->GetValue())) + { + SwWait aWait( *rView.GetDocShell(), TRUE ); + + String aGrfName, aFltName; + const Graphic aGrf( pGal->GetGraphic() ); + + if( pGal->IsLinkage() ) + { + // Verknuepft + aGrfName = pGal->GetURL().GetMainURL(INetURLObject::NO_DECODE); + aFltName = pGal->GetFilterName(); + } + + if ( nSelType & nsSelectionType::SEL_GRF ) + rSh.ReRead( aGrfName, aFltName, &aGrf ); + else + rSh.Insert( aGrfName, aFltName, aGrf ); + + GetView().GetEditWin().GrabFocus(); + } + else if(!rSh.IsSelFrmMode() && SGA_FORMAT_SOUND & ((SfxUInt32Item*)pItem)->GetValue()) + { + const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) ); + GetView().GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L ); +/* + String sURL( pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) ); + String sLabel( pGal->GetURL().getBase() ); + String sTarget; // empty string! + + bool bIsHTMLMode = + 0 == ( HTMLMODE_ON & + ::GetHtmlMode( GetView().GetDocShell() ) ); + + // in Writer, we insert a button which plays the + // sound. In Writer/Web, we just insert a (text) link. + if( bIsHTMLMode ) + InsertURLButton( sURL, sTarget, sLabel ); + else + rSh.InsertURL( SwFmtINetFmt( sURL, sTarget ), sLabel ); +*/ + } + } + } + break; + case FN_PAGE_STYLE_SET_COLS: + { + if (pArgs) + { + // aktuellen PageDescriptor ermitteln und damit den Set fuellen + const USHORT nCurIdx = rSh.GetCurPageDesc(); + SwPageDesc aPageDesc(rSh.GetPageDesc(nCurIdx)); + + SwFrmFmt &rFmt = aPageDesc.GetMaster(); + + SwFmtCol aFmtCol = rFmt.GetCol(); + + USHORT nCount; + if(SFX_ITEM_SET == pArgs->GetItemState(nSlot)) + nCount = ((SfxUInt16Item &)pArgs->Get(nSlot)).GetValue(); + else + nCount = ((SfxUInt16Item &)pArgs->Get(SID_ATTR_COLUMNS)).GetValue(); + USHORT nGutterWidth = DEF_GUTTER_WIDTH; + + aFmtCol.Init(nCount ? nCount : 1, nGutterWidth, USHRT_MAX); + aFmtCol.SetWishWidth(USHRT_MAX); + aFmtCol.SetGutterWidth(nGutterWidth, USHRT_MAX); + + rFmt.SetFmtAttr(aFmtCol); + + rSh.ChgPageDesc(nCurIdx, aPageDesc); + } + else + GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG, FALSE); + } + break; + case FN_CONVERT_TABLE_TO_TEXT: + case FN_CONVERT_TEXT_TO_TABLE: + case FN_CONVERT_TEXT_TABLE: + { + sal_Unicode cDelim = 0; + bool bToTable = false; + if( nSlot == FN_CONVERT_TEXT_TO_TABLE || + ( nSlot == FN_CONVERT_TEXT_TABLE && 0 == rSh.GetTableFmt() )) + bToTable = true; + SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 ); + SwTableAutoFmt* pTAFmt = 0; + SwTableAutoFmtTbl* pAutoFmtTbl = 0; + bool bDeleteFormat = true; + if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_1, TRUE, &pItem)) + { + aInsTblOpts.mnInsMode = 0; + //Delimiter + String sDelim = static_cast< const SfxStringItem* >(pItem)->GetValue(); + if(sDelim.Len()) + cDelim = sDelim.GetChar(0); + //AutoFormat + if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_2, TRUE, &pItem)) + { + String sAutoFmt = static_cast< const SfxStringItem* >(pItem)->GetValue(); + + pAutoFmtTbl = new SwTableAutoFmtTbl; + pAutoFmtTbl->Load(); + + for( USHORT i = 0, nCount = pAutoFmtTbl->Count(); i < nCount; i++ ) + { + SwTableAutoFmt* pFmt = (*pAutoFmtTbl)[ i ]; + if( pFmt->GetName() == sAutoFmt ) + { + pTAFmt = pFmt; + bDeleteFormat = false; + break; + } + } + } + //WithHeader + if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_3, TRUE, &pItem) && + static_cast< const SfxBoolItem* >(pItem)->GetValue()) + aInsTblOpts.mnInsMode |= tabopts::HEADLINE; + // RepeatHeaderLines + if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_4, TRUE, &pItem)) + aInsTblOpts.mnRowsToRepeat = + (USHORT)static_cast< const SfxInt16Item* >(pItem)->GetValue(); + //WithBorder + if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_5, TRUE, &pItem) && + static_cast< const SfxBoolItem* >(pItem)->GetValue()) + aInsTblOpts.mnInsMode |= tabopts::DEFAULT_BORDER; + //DontSplitTable + if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_6, TRUE, &pItem) && + !static_cast< const SfxBoolItem* >(pItem)->GetValue() ) + aInsTblOpts.mnInsMode |= tabopts::SPLIT_LAYOUT; + } + else + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSwConvertTableDlg* pDlg = pFact->CreateSwConvertTableDlg( + GetView(),DLG_CONV_TEXT_TABLE , bToTable); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if( RET_OK == pDlg->Execute() ) + { + pDlg->GetValues( cDelim, aInsTblOpts, pTAFmt ); + + } + delete pDlg; + } + + if( cDelim ) + { + //Shellwechsel! + SwView& rSaveView = rView; + BOOL bInserted = FALSE; + //recording: + + SfxViewFrame* pViewFrame = GetView().GetViewFrame(); + if( SfxRequest::HasMacroRecorder(pViewFrame) ) + { + SfxRequest aReq( pViewFrame, nSlot); + aReq.AppendItem( SfxStringItem( FN_PARAM_1, String(cDelim) )); + if(bToTable) + { + if(pTAFmt) + aReq.AppendItem( SfxStringItem( FN_PARAM_2, pTAFmt->GetName())); + aReq.AppendItem( SfxBoolItem ( FN_PARAM_3, 0 != (aInsTblOpts.mnInsMode & tabopts::HEADLINE))); + aReq.AppendItem( SfxInt16Item( FN_PARAM_4, (short)aInsTblOpts.mnRowsToRepeat )); + aReq.AppendItem( SfxBoolItem ( FN_PARAM_5, 0 != (aInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER) )); + aReq.AppendItem( SfxBoolItem ( FN_PARAM_6, !(aInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT))); + } + aReq.Done(); + } + + if( !bToTable ) + rSh.TableToText( cDelim ); + else + { + bInserted = rSh.TextToTable( aInsTblOpts, cDelim, text::HoriOrientation::FULL, pTAFmt ); + } + rSh.EnterStdMode(); + + if( bInserted ) + rSaveView.AutoCaption( TABLE_CAP ); + } + if(bDeleteFormat) + delete pTAFmt; + delete pAutoFmtTbl; + } + break; + case SID_STYLE_WATERCAN: + case SID_STYLE_UPDATE_BY_EXAMPLE: + case SID_STYLE_NEW_BY_EXAMPLE: + case SID_STYLE_APPLY: + { + ShellModes eMode = GetView().GetShellMode(); + if ( SHELL_MODE_DRAW != eMode && + SHELL_MODE_DRAW_CTRL != eMode && + SHELL_MODE_DRAW_FORM != eMode && + SHELL_MODE_DRAWTEXT != eMode && + SHELL_MODE_BEZIER != eMode ) + { + // oj #107754# + if ( SID_STYLE_WATERCAN == nSlot ) + { + const BOOL bLockedView = rSh.IsViewLocked(); + rSh.LockView( TRUE ); //lock visible section + + GetView().GetDocShell()->ExecStyleSheet(rReq); + + rSh.LockView( bLockedView ); + } + else + // wird von der DocShell aufgezeichnet + GetView().GetDocShell()->ExecStyleSheet(rReq); + } + } + break; + case FN_ESCAPE: + GetView().ExecuteSlot(rReq); + break; + case SID_IMAP: + { + USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId(); + + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + pVFrame->ToggleChildWindow( nId ); + pVFrame->GetBindings().Invalidate( SID_IMAP ); + + if ( pVFrame->HasChildWindow( nId ) && rSh.IsFrmSelected() ) + lcl_UpdateIMapDlg( rSh ); + } + break; + case SID_IMAP_EXEC: + { + SvxIMapDlg* pDlg = SWIMAPDLG(GetView()); + + // Kontrolle, ob Zuweisung ueberhaupt sinnvoll/erlaubt + if ( rSh.IsFrmSelected() && + pDlg->GetEditingObject() == rSh.GetIMapInventor() ) + { + SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); + rSh.GetFlyFrmAttr( aSet ); + SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) ); + aURL.SetMap( &pDlg->GetImageMap() ); + aSet.Put( aURL ); + rSh.SetFlyFrmAttr( aSet ); + } + } + break; + case SID_CONTOUR_DLG: + { + USHORT nId = SvxContourDlgChildWindow::GetChildWindowId(); + + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + pVFrame->ToggleChildWindow( nId ); + pVFrame->GetBindings().Invalidate( SID_CONTOUR_DLG ); + + int nSel = rSh.GetSelectionType(); + if ( pVFrame->HasChildWindow( nId ) && + (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) ) + { + lcl_UpdateContourDlg( rSh, nSel ); + } + } + break; + case SID_CONTOUR_EXEC: + { + SvxContourDlg *pDlg = SWCONTOURDLG(GetView()); + + // Kontrolle, ob Zuweisung ueberhaupt sinnvoll/erlaubt + int nSel = rSh.GetSelectionType(); + if ( nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE) ) + { + if ( pDlg->GetEditingObject() == rSh.GetIMapInventor() ) + { + rSh.StartAction(); + SfxItemSet aSet( rSh.GetAttrPool(), RES_SURROUND, RES_SURROUND); + rSh.GetFlyFrmAttr( aSet ); + SwFmtSurround aSur( (SwFmtSurround&)aSet.Get( RES_SURROUND ) ); + if ( !aSur.IsContour() ) + { + aSur.SetContour( TRUE ); + if ( aSur.GetSurround() == SURROUND_NONE ) + aSur.SetSurround( SURROUND_PARALLEL ); + aSet.Put( aSur ); + rSh.SetFlyFrmAttr( aSet ); + } + const PolyPolygon aPoly( pDlg->GetPolyPolygon() ); + rSh.SetGraphicPolygon( &aPoly ); + if ( pDlg->IsGraphicChanged() ) + rSh.ReRead( aEmptyStr, aEmptyStr, &pDlg->GetGraphic()); + rSh.EndAction(); + } + } + } + break; + case FN_FRAME_TO_ANCHOR: + { + rSh.GotoFlyAnchor(); + rSh.EnterStdMode(); + rSh.CallChgLnk(); + } + break; + case FN_TOOL_ANKER: + break; + case FN_TOOL_ANKER_PAGE: + case FN_TOOL_ANKER_PARAGRAPH: + case FN_TOOL_ANKER_CHAR: + case FN_TOOL_ANKER_AT_CHAR: + case FN_TOOL_ANKER_FRAME: + { + RndStdIds eSet = nSlot == FN_TOOL_ANKER_PAGE + ? FLY_AT_PAGE + : nSlot == FN_TOOL_ANKER_PARAGRAPH + ? FLY_AT_PARA + : nSlot == FN_TOOL_ANKER_FRAME + ? FLY_AT_FLY + : nSlot == FN_TOOL_ANKER_CHAR + ? FLY_AS_CHAR + : FLY_AT_CHAR; + rSh.StartUndo(); + if( rSh.IsObjSelected() ) + rSh.ChgAnchor( eSet ); + else if( rSh.IsFrmSelected() ) + { + // Der Set beinhaltet auch VERT/HORI_ORIENT, da in FEShell:: + // SetFlyFrmAttr/SetFlyFrmAnchor ggf. als Folge des Umankerns + // die Ausrichtungen veraendert werden sollen. + SfxItemSet aSet( GetPool(), RES_VERT_ORIENT, RES_ANCHOR ); + SwFmtAnchor aAnc( eSet, rSh.GetPhyPageNum() ); + aSet.Put( aAnc ); + rSh.SetFlyFrmAttr(aSet); + } + + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + if( nHtmlMode ) + { + SfxItemSet aSet(GetPool(), RES_SURROUND, RES_HORI_ORIENT); + rSh.GetFlyFrmAttr(aSet); + + const SwFmtSurround& rSurround = (const SwFmtSurround&)aSet.Get(RES_SURROUND); + const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT); + const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT); + sal_Int16 eVOrient = rVert.GetVertOrient(); + sal_Int16 eHOrient = rHori.GetHoriOrient(); + SwSurround eSurround = rSurround.GetSurround(); + + switch( eSet ) + { + case FLY_AT_FLY: + case FLY_AT_PAGE: + + //Durchlauf, links oder von links, oben, von oben + if(eSurround != SURROUND_THROUGHT) + aSet.Put(SwFmtSurround(SURROUND_THROUGHT)); + + if( eVOrient != text::VertOrientation::TOP && eVOrient != text::VertOrientation::NONE) + aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP)); + + if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT) + aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); + break; + + case FLY_AT_PARA: + //links, von links, rechts, oben, kein Uml, li+re Umlauf, + if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT) + aSet.Put(SwFmtSurround(SURROUND_LEFT)); + + if( eVOrient != text::VertOrientation::TOP) + aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP)); + + if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT) + aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); + break; + + case FLY_AT_CHAR: + //links, von links, rechts, oben, Durchlauf + if(eSurround != SURROUND_THROUGHT) + aSet.Put(SwFmtSurround(SURROUND_THROUGHT)); + + if( eVOrient != text::VertOrientation::TOP) + aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP)); + + if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT) + aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); + break; + + default: + ; + } + + if( aSet.Count() ) + rSh.SetFlyFrmAttr( aSet ); + } + rSh.EndUndo(); + + GetView().GetViewFrame()->GetBindings().Invalidate( FN_TOOL_ANKER ); + } + break; + + case FN_FRAME_NOWRAP: + case FN_FRAME_WRAP: + case FN_FRAME_WRAP_IDEAL: + case FN_FRAME_WRAPTHRU: + case FN_FRAME_WRAPTHRU_TRANSP: + case FN_FRAME_WRAP_CONTOUR: + case FN_WRAP_ANCHOR_ONLY: + case FN_FRAME_WRAP_LEFT: + case FN_FRAME_WRAP_RIGHT: + SetWrapMode( nSlot ); + break; + + case FN_UPDATE_ALL_LINKS: + { + if( rSh.GetLinkManager().GetLinks().Count() ) + { + BOOL bUpdateGrf = FALSE, bCallErrHdl = FALSE; + rSh.EnterStdMode(); + rSh.StartAllAction(); + rSh.GetLinkManager().UpdateAllLinks( FALSE, bCallErrHdl, bUpdateGrf ); + rSh.EndAllAction(); + } + } + break; + + case FN_XFORMS_DESIGN_MODE: + if( pArgs != NULL + && pArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET + && pItem != NULL + && pItem->ISA( SfxBoolItem ) ) + { + BOOL bDesignMode = + static_cast<const SfxBoolItem*>( pItem )->GetValue(); + + // set form design mode + DBG_ASSERT( GetView().GetFormShell() != NULL, "form shell?" ); + SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE ); + aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) ); + GetView().GetFormShell()->Execute( aReq ); + aReq.Done(); + + // also set suitable view options + SwViewOption aViewOption = *rSh.GetViewOptions(); + aViewOption.SetFormView( ! bDesignMode ); + rSh.ApplyViewOptions( aViewOption ); + } + break; + + default: + bMore = TRUE; + } + if(bMore && pArgs) + { + pItem = 0; + pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem); + if(pItem) + switch(nSlot) + { + case SID_ATTR_BRUSH: + case SID_ATTR_BORDER_SHADOW: + case RES_SHADOW: + { + rSh.StartAllAction(); + SfxItemSet aSet( rSh.GetAttrPool(), + RES_SHADOW, RES_SHADOW, + RES_BACKGROUND, RES_BACKGROUND, 0 ); + + aSet.Put(*pItem); + // Tabellenzelle(n) selektiert? + if ( rSh.IsTableMode() ) + { + SwFrmFmt *pFmt = rSh.GetTableFmt(); + pFmt->SetFmtAttr( *pItem ); + } + else if ( rSh.IsFrmSelected() ) + { + // Umrandungsattribute ueber Frame-Manager setzen + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + aMgr.SetAttrSet( *pArgs ); + aMgr.UpdateFlyFrm(); + } + else + { + rSh.SetAttr( *pArgs ); + } + rSh.EndAllAction(); + } + break; + case FN_PAGE_STYLE_SET_LR_MARGIN: + case FN_PAGE_STYLE_SET_UL_MARGIN: + case FN_PAGE_STYLE_SET_NUMBER_FORMAT: + case FN_PAGE_STYLE_SET_PAPER_SIZE: + case FN_PAGE_STYLE_SET_PAPER_BIN: + { + DBG_ERROR("not implemented"); + } + break; + + case SID_ATTR_BORDER_OUTER: + { + // Tabellenzelle(n) selektiert? + if ( rSh.IsTableMode() ) + { + // Umrandungattribute Get/SetTabBorders() setzen + rSh.SetTabBorders(*pArgs); + } + else if ( rSh.IsFrmSelected() ) + { + // Umrandungsattribute ueber Frame-Manager setzen + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + aMgr.SetAttrSet(*pArgs); + aMgr.UpdateFlyFrm(); + } + else + { + // Umrandungsattribute ganz normal ueber Shell setzen + rSh.SetAttr( *pItem ); + } + } + break; + default: + DBG_ERROR("falscher Dispatcher"); + } + + } +} + +/* -----------------14.04.99 15:10------------------- + * Hier wird der State fuer SID_IMAP / SID_CONTOUR behandelt, + * wenn die Grafik ausgeswappt ist + * --------------------------------------------------*/ +IMPL_LINK(SwBaseShell, GraphicArrivedHdl, SwCrsrShell* , EMPTYARG ) +{ + USHORT nGrfType; + SwWrtShell &rSh = GetShell(); + if( CNT_GRF == rSh.SwEditShell::GetCntType() && + GRAPHIC_NONE != ( nGrfType = rSh.GetGraphicType() ) && + aGrfUpdateSlots.Count() ) + { + BOOL bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + USHORT nSlot; + for( USHORT n = 0; n < aGrfUpdateSlots.Count(); ++n ) + { + BOOL bSetState = FALSE; + BOOL bState = FALSE; + switch( nSlot = aGrfUpdateSlots[ n ] ) + { + case SID_IMAP: + case SID_IMAP_EXEC: + { + USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId(); + SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ? + (SvxIMapDlg*) ( pVFrame->GetChildWindow( nId ) + ->GetWindow()) : 0; + + if( pDlg && ( SID_IMAP_EXEC == nSlot || + ( SID_IMAP == nSlot && !bProtect)) && + pDlg->GetEditingObject() != rSh.GetIMapInventor()) + lcl_UpdateIMapDlg( rSh ); + + if( !bProtect && SID_IMAP == nSlot ) + bSetState = TRUE, bState = 0 != pDlg; + } + break; + + case SID_CONTOUR_DLG: + if( !bProtect ) + { + USHORT nId = SvxContourDlgChildWindow::GetChildWindowId(); + SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ? + (SvxIMapDlg*) ( pVFrame->GetChildWindow( nId ) + ->GetWindow()) : 0; + if( pDlg && pDlg->GetEditingObject() != + rSh.GetIMapInventor() ) + lcl_UpdateContourDlg( rSh, nsSelectionType::SEL_GRF ); + + bSetState = TRUE; + bState = 0 != pDlg; + } + break; + + case FN_FRAME_WRAP_CONTOUR: + if( !bProtect ) + { + SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND); + rSh.GetFlyFrmAttr(aSet); + const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND); + bSetState = TRUE; + bState = rWrap.IsContour(); + } + break; + + case SID_GRFFILTER: + case SID_GRFFILTER_INVERT: + case SID_GRFFILTER_SMOOTH: + case SID_GRFFILTER_SHARPEN: + case SID_GRFFILTER_REMOVENOISE: + case SID_GRFFILTER_SOBEL: + case SID_GRFFILTER_MOSAIC: + case SID_GRFFILTER_EMBOSS: + case SID_GRFFILTER_POSTER: + case SID_GRFFILTER_POPART: + case SID_GRFFILTER_SEPIA: + case SID_GRFFILTER_SOLARIZE: + bSetState = bState = GRAPHIC_BITMAP == nGrfType; + break; + } + + if( bSetState ) + { + SfxBoolItem aBool( nSlot, bState ); + if( pGetStateSet ) + pGetStateSet->Put( aBool ); + else + pVFrame->GetBindings().SetState( aBool ); + } + } + aGrfUpdateSlots.RemoveAt( 0, aGrfUpdateSlots.Count() ); + } + return 0; +} + +void SwBaseShell::GetState( SfxItemSet &rSet ) +{ + SwWrtShell &rSh = GetShell(); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + pGetStateSet = &rSet; + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_GALLERY_FORMATS: + if ( rSh.IsObjSelected() || + (rSh.IsSelFrmMode() && + !(rSh.GetSelectionType() & nsSelectionType::SEL_GRF)) ) + rSet.DisableItem( nWhich ); + break; + case SID_GALLERY_ENABLE_ADDCOPY: + // #108230# allow copy from gallery in Writer AND Writer/Web! + rSet.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY, TRUE ) ); + break; + case FN_EDIT_REGION: + if( !rSh.IsAnySectionInDoc() ) + rSet.DisableItem(nWhich); + break; + + case FN_INSERT_REGION: + if( rSh.IsSelFrmMode() || + !rSh.IsInsRegionAvailable() ) + rSet.DisableItem( nWhich ); + break; + case FN_CONVERT_TABLE_TO_TEXT: + { + USHORT eFrmType = rSh.GetFrmType(0,TRUE); + if( (eFrmType & FRMTYPE_FOOTNOTE) || + !rSh.GetTableFmt() ) + rSet.DisableItem( nWhich ); + } + break; + case FN_CONVERT_TEXT_TO_TABLE: + { + USHORT eFrmType = rSh.GetFrmType(0,TRUE); + if( (eFrmType & FRMTYPE_FOOTNOTE) || + !rSh.IsTextToTableAvailable() ) + rSet.DisableItem( nWhich ); + } + break; + case FN_CONVERT_TEXT_TABLE: + { + USHORT eFrmType = rSh.GetFrmType(0,TRUE); + if( (eFrmType & FRMTYPE_FOOTNOTE) || + (!rSh.GetTableFmt() && !rSh.IsTextToTableAvailable() ) ) + rSet.DisableItem( nWhich ); + } + break; + case RES_SHADOW: + { + SfxItemSet aSet( rSh.GetAttrPool(), + RES_SHADOW, RES_SHADOW ); + + // Tabellenzelle(n) selektiert? + if ( rSh.IsTableMode() ) + { + SwFrmFmt *pFmt = rSh.GetTableFmt(); + aSet.Put(pFmt->GetFmtAttr( nWhich, TRUE )); + } + else if( rSh.IsFrmSelected() ) + { + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + aSet.Put( aMgr.GetAttrSet() ); + } + else + rSh.GetCurAttr( aSet ); +#if OSL_DEBUG_LEVEL > 1 + + const SvxShadowItem& rShItem = (const SvxShadowItem&)aSet.Get(nWhich); + rSet.Put(rShItem); +#else + rSet.Put((const SvxShadowItem&)aSet.Get(nWhich)); +#endif + } + break; + case SID_IMAP: + { + // --> OD 2006-11-08 #i59688# + // improve efficiency: + // If selected object is protected, item has to disabled. + const BOOL bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT); + if ( bProtect ) + { + rSet.DisableItem( nWhich ); + } + else + { + const USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId(); + const BOOL bHas = pVFrame->HasChildWindow( nId ); + const BOOL bFrmSel = rSh.IsFrmSelected(); + const BOOL bIsGraphicSelection = + rSh.GetSelectionType() == nsSelectionType::SEL_GRF; + + // --> OD 2006-11-08 #i59688# + // avoid unnecessary loading of selected graphic. + // The graphic is only needed, if the dialog is open. + //wenn die Grafik ausgeswappt ist, dann muss der + //Status asynchron ermittelt werden + //bis dahin wird der Slot disabled + if ( bHas && bIsGraphicSelection && rSh.IsGrfSwapOut( TRUE ) ) + { + if( AddGrfUpdateSlot( nWhich )) + rSh.GetGraphic(FALSE); // start the loading + } + else + { + if ( !bHas && + ( !bFrmSel || + ( bIsGraphicSelection && + rSh.GetGraphicType() == GRAPHIC_NONE ) ) ) + { + rSet.DisableItem( nWhich ); + } + else + { + SfxBoolItem aBool(nWhich, bHas); + if ( bHas && bFrmSel ) + lcl_UpdateIMapDlg( rSh ); + rSet.Put(aBool); + } + } + // <-- + } + // <-- + } + break; + case SID_IMAP_EXEC: + { + BOOL bDisable = FALSE; + if( !rSh.IsFrmSelected()) + bDisable = TRUE; + USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId(); + if(!bDisable && pVFrame->HasChildWindow( nId )) + { + if(rSh.GetSelectionType() == nsSelectionType::SEL_GRF + && rSh.IsGrfSwapOut(TRUE)) + { + if( AddGrfUpdateSlot( nWhich )) + rSh.GetGraphic(FALSE); // start the loading + } + else + { + SvxIMapDlg *pDlg = SWIMAPDLG(GetView()); + if( pDlg->GetEditingObject() != rSh.GetIMapInventor() ) + lcl_UpdateIMapDlg( rSh ); + } + } + rSet.Put(SfxBoolItem(nWhich, bDisable)); + } + break; + case FN_BACKSPACE: + case SID_DELETE: + if (rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0) + rSet.DisableItem( nWhich ); + break; + case SID_CONTOUR_DLG: + { + BOOL bParentCntProt = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT ); + + if( bParentCntProt || 0 != (HTMLMODE_ON & ::GetHtmlMode( + GetView().GetDocShell() )) ) + rSet.DisableItem( nWhich ); + else + { + USHORT nId = SvxContourDlgChildWindow::GetChildWindowId(); + BOOL bHas = GetView().GetViewFrame()->HasChildWindow( nId ); + int nSel = rSh.GetSelectionType(); + BOOL bOk = 0 != (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)); + + BOOL bDisable = FALSE; + if( !bHas && !bOk ) + bDisable = TRUE; + // --> OD 2006-11-08 #i59688# + // avoid unnecessary loading of selected graphic. + // The graphic is only needed, if the dialog is open. + // wenn die Grafik ausgeswappt ist, dann muss der Status + // asynchron ermittelt werden bis dahin wird der Slot + // disabled + else if ( bHas && (nSel & nsSelectionType::SEL_GRF) && + rSh.IsGrfSwapOut(TRUE) ) + { + if( AddGrfUpdateSlot( nWhich )) + rSh.GetGraphic(FALSE); // start the loading + // --> OD 2007-07-04 #i75481# + bDisable = TRUE; + // <-- + } + else if( bHas && bOk ) + bDisable = !lcl_UpdateContourDlg( rSh, nSel ); + else if( bOk ) + { + // --> OD 2007-07-04 #i75481# + // apply fix #i59688# only for selected graphics + if ( nSel & nsSelectionType::SEL_GRF ) + bDisable = GRAPHIC_NONE == rSh.GetGraphicType(); + else + bDisable = GRAPHIC_NONE == rSh.GetIMapGraphic().GetType(); + // <-- + } + // <-- + + if( bDisable ) + rSet.DisableItem( nWhich ); + else + rSet.Put( SfxBoolItem(nWhich, bHas) ); + } + } + break; + case SID_CONTOUR_EXEC: + { + BOOL bDisable = FALSE; + int nSel = rSh.GetSelectionType(); + if( !(nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) ) + bDisable = TRUE; + USHORT nId = SvxContourDlgChildWindow::GetChildWindowId(); + if( !bDisable && GetView().GetViewFrame()->HasChildWindow( nId )) + { + SvxContourDlg *pDlg = SWCONTOURDLG(GetView()); + if( pDlg->GetEditingObject() != rSh.GetIMapInventor() ) + bDisable = TRUE; + } + rSet.Put(SfxBoolItem(nWhich, bDisable)); + } + break; + + case FN_TOOL_ANKER: + case FN_TOOL_ANKER_PAGE: + case FN_TOOL_ANKER_PARAGRAPH: + case FN_TOOL_ANKER_CHAR: + case FN_TOOL_ANKER_AT_CHAR: + case FN_TOOL_ANKER_FRAME: + { + BOOL bObj = 0 != rSh.IsObjSelected(); + BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + + if( !bParentCntProt && (bObj || rSh.IsFrmSelected())) + { + SfxItemSet aSet(GetPool(), RES_ANCHOR, RES_ANCHOR); + if(bObj) + rSh.GetObjAttr(aSet); + else + rSh.GetFlyFrmAttr(aSet); + RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId(); + const BOOL bSet = + ((nWhich == FN_TOOL_ANKER_PAGE) && + (eSet == FLY_AT_PAGE)) + || ((nWhich == FN_TOOL_ANKER_PARAGRAPH) && + (eSet == FLY_AT_PARA)) + || ((nWhich == FN_TOOL_ANKER_FRAME) && + (eSet == FLY_AT_FLY)) + || ((nWhich == FN_TOOL_ANKER_AT_CHAR) && + (eSet == FLY_AT_CHAR)) + || ((nWhich == FN_TOOL_ANKER_CHAR) && + (eSet == FLY_AS_CHAR)); + if(nWhich != FN_TOOL_ANKER) + { + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + if( ( nWhich == FN_TOOL_ANKER_PAGE && + ((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)))) || + ( nWhich == FN_TOOL_ANKER_FRAME && !rSh.IsFlyInFly() ) ) + rSet.DisableItem(nWhich); + else + rSet.Put(SfxBoolItem(nWhich, bSet)); + } + else + { + USHORT nSlotId = 0; + + switch (eSet) + { + case FLY_AT_PAGE: + nSlotId = FN_TOOL_ANKER_PAGE; + break; + case FLY_AT_PARA: + nSlotId = FN_TOOL_ANKER_PARAGRAPH; + break; + case FLY_AS_CHAR: + nSlotId = FN_TOOL_ANKER_CHAR; + break; + case FLY_AT_CHAR: + nSlotId = FN_TOOL_ANKER_AT_CHAR; + break; + case FLY_AT_FLY: + nSlotId = FN_TOOL_ANKER_FRAME; + break; + default: + ; + } + rSet.Put(SfxUInt16Item(nWhich, nSlotId)); + } + } + else + rSet.DisableItem( nWhich ); + } + break; + case FN_FRAME_NOWRAP: + case FN_FRAME_WRAP: + case FN_FRAME_WRAP_IDEAL: + case FN_FRAME_WRAPTHRU: + case FN_FRAME_WRAPTHRU_TRANSP: + case FN_FRAME_WRAP_CONTOUR: + case FN_WRAP_ANCHOR_ONLY: + case FN_FRAME_WRAP_LEFT: + case FN_FRAME_WRAP_RIGHT: + { + BOOL bObj = 0 != rSh.IsObjSelected(); + BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + + if( !bParentCntProt && (bObj || rSh.IsFrmSelected())) + { + SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_ANCHOR); + int nAnchorType; + if(bObj) + { + rSh.GetObjAttr(aSet); + nAnchorType = rSh.GetAnchorId(); + } + else + { + rSh.GetFlyFrmAttr(aSet); + nAnchorType = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId(); + } + const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND); + + const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)aSet.Get(RES_OPAQUE); + BOOL bOpaque = rOpaque.GetValue(); + SwSurround nSurround = rWrap.GetSurround(); + BOOL bSet = FALSE; + + bool bDisable = + (nAnchorType == - 1) || (nAnchorType == FLY_AS_CHAR); + const bool bHtmlMode = + 0 != ::GetHtmlMode(GetView().GetDocShell()); + + switch( nWhich ) + { + case FN_FRAME_NOWRAP: + bDisable |= + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE)); + bSet = nSurround == SURROUND_NONE; + break; + case FN_FRAME_WRAP: + bDisable |= bHtmlMode; + bSet = nSurround == SURROUND_PARALLEL; + break; + case FN_FRAME_WRAP_IDEAL: + bDisable |= bHtmlMode; + bSet = nSurround == SURROUND_IDEAL; + break; + case FN_FRAME_WRAPTHRU: + bDisable |= (bHtmlMode || + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE))); + if(bObj) + bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId(); + else + bSet = nSurround == SURROUND_THROUGHT && bOpaque; + break; + case FN_FRAME_WRAPTHRU_TRANSP: + bDisable |= bHtmlMode; + if(bObj) + bSet = nSurround == SURROUND_THROUGHT && !rSh.GetLayerId(); + else + bSet = nSurround == SURROUND_THROUGHT && !bOpaque; + break; + case FN_FRAME_WRAP_CONTOUR: + bDisable |= bHtmlMode; + //no contour available whenn no wrap or wrap through is set + bDisable |= (nSurround == SURROUND_NONE || nSurround == SURROUND_THROUGHT); + bSet = rWrap.IsContour(); + if( !bDisable ) + { + int nSel = rSh.GetSelectionType(); + if( (nSel & nsSelectionType::SEL_GRF) && + rSh.IsGrfSwapOut(TRUE)) + { + if( AddGrfUpdateSlot( nWhich )) + rSh.GetGraphic(FALSE); // start the loading + } + else if( rSh.IsFrmSelected() ) + { + // #i102253# applied patch from OD (see task) + bDisable = + nSel & nsSelectionType::SEL_FRM || + GRAPHIC_NONE == rSh.GetIMapGraphic().GetType(); + } + } + bSet = bDisable ? FALSE : rWrap.IsContour(); + + break; + case FN_WRAP_ANCHOR_ONLY: + bDisable |= (bHtmlMode || + (nAnchorType != FLY_AT_PARA)); + bSet = rWrap.IsAnchorOnly(); + break; + case FN_FRAME_WRAP_LEFT: + bSet = nSurround == SURROUND_LEFT; + break; + case FN_FRAME_WRAP_RIGHT: + bSet = nSurround == SURROUND_RIGHT; + break; + } + + if(bDisable) + rSet.DisableItem(nWhich); + else + rSet.Put(SfxBoolItem(nWhich, bSet)); + } + else + rSet.DisableItem(nWhich); + } + break; + case FN_UPDATE_CHARTS: + if( !rSh.HasCharts() ) + rSet.DisableItem( nWhich ); + break; + case FN_UPDATE_ALL_LINKS: + if ( !rSh.GetLinkManager().GetLinks().Count() ) + rSet.DisableItem(nWhich); + break; + case FN_XFORMS_DESIGN_MODE: + // enable if in XForms document + if( rSh.GetDoc()->isXForms() ) + { + // determine current state from view options + sal_Bool bValue = ! rSh.GetViewOptions()->IsFormView(); + rSet.Put( SfxBoolItem( nWhich, bValue ) ); + } + else + rSet.Put( SfxVisibilityItem( nWhich, sal_False ) ); + break; + } + nWhich = aIter.NextWhich(); + } + pGetStateSet = 0; +} + +/*-------------------------------------------------------------------- + Beschreibung: Slots mit dieser Statusmethode disablen + --------------------------------------------------------------------*/ + + +void SwBaseShell::StateDisableItems( SfxItemSet &rSet ) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Slots mit dieser Statusmethode disablen + --------------------------------------------------------------------*/ + + +void SwBaseShell::StateStyle( SfxItemSet &rSet ) +{ + BOOL bParentCntProt = GetShell().IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + ShellModes eMode = GetView().GetShellMode(); + + if ( bParentCntProt || + SHELL_MODE_DRAW == eMode || + SHELL_MODE_DRAW_CTRL == eMode || + SHELL_MODE_DRAW_FORM == eMode || + SHELL_MODE_DRAWTEXT == eMode || + SHELL_MODE_BEZIER == eMode ) + { + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } + } + else + GetView().GetDocShell()->StateStyleSheet(rSet, &GetShell()); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwBaseShell::SetWrapMode( USHORT nSlot ) +{ + SwWrtShell &rSh = GetShell(); + BOOL bObj = 0 != rSh.IsObjSelected(); + if( bObj || rSh.IsFrmSelected()) + { + SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_SURROUND); + if(bObj) + rSh.GetObjAttr(aSet); + else + rSh.GetFlyFrmAttr(aSet); + SwFmtSurround aWrap( (SwFmtSurround&)aSet.Get(RES_SURROUND) ); + SwSurround nOldSurround(aWrap.GetSurround()); + SwSurround nSurround = SURROUND_PARALLEL; + + switch (nSlot) + { + case FN_FRAME_NOWRAP: + nSurround = SURROUND_NONE; + if (aWrap.IsContour()) + aWrap.SetContour(FALSE); + break; + case FN_FRAME_WRAP_IDEAL: + nSurround = SURROUND_IDEAL; + break; + case FN_WRAP_ANCHOR_ONLY: + aWrap.SetAnchorOnly(!aWrap.IsAnchorOnly()); + // --> OD 2006-06-02 #b6432130# + // keep previous wrapping + // --> OD 2006-09-21 #138144# - adjust fix #b6432130# + // switch to wrap SURROUND_PARALLEL, if previous wrap is SURROUND_NONE + if ( nOldSurround != SURROUND_NONE ) + { + nSurround = nOldSurround; + } + // <-- + break; + case FN_FRAME_WRAP_CONTOUR: + aWrap.SetContour(!aWrap.IsContour()); + if (nSurround == SURROUND_THROUGHT) + nSurround = SURROUND_PARALLEL; + break; + case FN_FRAME_WRAPTHRU_TRANSP: + if (aWrap.IsContour()) + aWrap.SetContour(FALSE); + // kein break!!! + case FN_FRAME_WRAPTHRU: + nSurround = SURROUND_THROUGHT; + break; + + case FN_FRAME_WRAP_LEFT: + nSurround = SURROUND_LEFT; + break; + + case FN_FRAME_WRAP_RIGHT: + nSurround = SURROUND_RIGHT; + break; + + default: + break; + } + aWrap.SetSurround(nSurround); + + if (nSlot != FN_FRAME_WRAP_CONTOUR) + { + // Konturumfluss bei Draw-Objekten defaulten + if (bObj && nOldSurround != nSurround && + (nOldSurround == SURROUND_NONE || nOldSurround == SURROUND_THROUGHT)) + { + aWrap.SetContour(TRUE); + } + } + + aSet.Put( aWrap ); + aSet.Put(SvxOpaqueItem(RES_OPAQUE, nSlot != FN_FRAME_WRAPTHRU_TRANSP)); + if(bObj) + { + rSh.SetObjAttr(aSet); + if (nSlot != FN_FRAME_WRAPTHRU_TRANSP) + rSh.SelectionToHeaven(); + else + rSh.SelectionToHell(); + } + else + rSh.SetFlyFrmAttr(aSet); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Update der Statuszeile erzwingen + --------------------------------------------------------------------*/ + +void SwBaseShell::SetFrmMode(FlyMode eMode, SwWrtShell *pSh ) +{ + eFrameMode = eMode; + SfxBindings &rBnd = pSh->GetView().GetViewFrame()->GetBindings(); + + if( eMode == FLY_DRAG || + (pSh && (pSh->IsFrmSelected() || pSh->IsObjSelected())) ) + { + const SfxPointItem aTmp1( SID_ATTR_POSITION, pSh->GetAnchorObjDiff()); + const SvxSizeItem aTmp2( SID_ATTR_SIZE, pSh->GetObjSize()); + rBnd.SetState( aTmp1 ); + rBnd.SetState( aTmp2 ); + } + else if( eMode == FLY_DRAG_END ) + { + static USHORT __READONLY_DATA aInval[] = + { + SID_ATTR_POSITION, SID_ATTR_SIZE, 0 + }; + rBnd.Invalidate(aInval); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Ctor + --------------------------------------------------------------------*/ + +SwBaseShell::SwBaseShell(SwView& rVw) : + SfxShell( &rVw ), + rView(rVw), + pGetStateSet(0) +{ + SwWrtShell& rWrtSh = rView.GetWrtShell(); + + SetPool(&rWrtSh.GetAttrPool()); + SetName(C2S("Base")); + rWrtSh.SetGrfArrivedLnk( LINK( this, SwBaseShell, GraphicArrivedHdl)); +} + + +SwBaseShell::~SwBaseShell() +{ + if( rView.GetCurShell() == this ) + rView.ResetSubShell(); + + Link aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl)); + if( aTmp == rView.GetWrtShell().GetGrfArrivedLnk() ) + rView.GetWrtShell().SetGrfArrivedLnk( Link() ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) +{ + const SfxItemSet *pArgs = rReq.GetArgs(); + + if( pArgs) + { + SwWrtShell &rSh = GetShell(); + SvxScriptSetItem* pSSetItem = 0; + USHORT nSlot = rReq.GetSlot(); + SfxItemPool& rPool = rSh.GetAttrPool(); + USHORT nWhich = rPool.GetWhich( nSlot ); + USHORT nScripts = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; + SfxItemSet aHeightSet( GetPool(), RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE, + RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, + RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE, + 0L); + + switch( nSlot ) + { + case SID_ATTR_CHAR_FONT: + { + nScripts = rSh.GetScriptType(); + // #i42732# input language should be preferred over + // current cursor position to detect script type + if(!rSh.HasSelection()) + { + LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage(); + if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) + nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); + } + } + case SID_ATTR_CHAR_POSTURE: + case SID_ATTR_CHAR_WEIGHT: + { + pSSetItem = new SvxScriptSetItem( nSlot, rPool ); + pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); + pArgs = &pSSetItem->GetItemSet(); + } + break; + case SID_ATTR_CHAR_FONTHEIGHT: + { + if(rSh.HasSelection()) + { + pSSetItem = new SvxScriptSetItem( nSlot, rPool ); + pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); + pArgs = &pSSetItem->GetItemSet(); + } + else + { + nScripts = rSh.GetScriptType(); + LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage(); + if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) + nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); + UINT32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight(); + SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig(); + + SfxItemSet aLangSet( GetPool(), RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, + RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, + RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, + 0L); + rSh.GetCurAttr( aLangSet ); + + sal_Int32 nWesternSize = + pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_DEFAULT, + static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_LANGUAGE)).GetLanguage()); + sal_Int32 nCJKSize = + pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CJK, + static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CJK_LANGUAGE)).GetLanguage()); + sal_Int32 nCTLSize = + pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CTL, + static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CTL_LANGUAGE)).GetLanguage()); + + switch(nScripts) + { + case SCRIPTTYPE_LATIN: + nCJKSize = nHeight * nCJKSize / nWesternSize; + nCTLSize = nHeight * nCTLSize / nWesternSize; + nWesternSize = (sal_Int32) nHeight; + break; + case SCRIPTTYPE_ASIAN: + nCTLSize = nHeight* nCTLSize / nCJKSize; + nWesternSize = nHeight * nWesternSize / nCJKSize; + nCJKSize = (sal_Int32) nHeight; + break; + case SCRIPTTYPE_COMPLEX: + nCJKSize = nHeight * nCJKSize / nCTLSize; + nWesternSize = nHeight * nWesternSize / nCTLSize; + nCTLSize = (sal_Int32) nHeight; + break; + } + aHeightSet.Put( SvxFontHeightItem( (UINT32)nWesternSize, 100, RES_CHRATR_FONTSIZE )); + aHeightSet.Put( SvxFontHeightItem( (UINT32)nCJKSize, 100, RES_CHRATR_CJK_FONTSIZE )); + aHeightSet.Put( SvxFontHeightItem( (UINT32)nCTLSize, 100, RES_CHRATR_CTL_FONTSIZE )); + pArgs = &aHeightSet; + } + } + break; + } + + if( pArgs ) + { + bool bAuto = false; + if ( !isCHRATR(nWhich) || + ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) + { + SwTxtFmtColl * pColl = rSh.GetCurTxtFmtColl(); + if ( pColl && pColl->IsAutoUpdateFmt() ) + { + rSh.AutoUpdatePara( pColl, *pArgs ); + bAuto = true; + } + } + + if (!bAuto) + { + rSh.SetAttr( *pArgs ); + } + } + delete pSSetItem; + } + else + GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG, FALSE); + rReq.Done(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwBaseShell::GetTxtCtrlState( SfxItemSet& rSet ) +{ + SwWrtShell &rSh = GetShell(); + rSh.GetCurAttr( rSet ); +} + +void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet ) +{ + SwWrtShell &rSh = GetShell(); + BOOL bFirst = TRUE; + SfxItemSet* pFntCoreSet = 0; + USHORT nScriptType = SCRIPTTYPE_LATIN; + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while( nWhich ) + { + switch( nWhich ) + { + case RES_CHRATR_FONT: + case RES_CHRATR_FONTSIZE: + case RES_CHRATR_WEIGHT: + case RES_CHRATR_POSTURE: + { + if( !pFntCoreSet ) + { + pFntCoreSet = new SfxItemSet( *rSet.GetPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END-1 ); + rSh.GetCurAttr( *pFntCoreSet ); + nScriptType = rSh.GetScriptType(); + // #i42732# input language should be preferred over + // current cursor position to detect script type + SwEditWin& rEditWin = GetView().GetEditWin(); + if( rEditWin.IsUseInputLanguage() ) + { + if(!rSh.HasSelection() && ( + nWhich == RES_CHRATR_FONT || + nWhich == RES_CHRATR_FONTSIZE )) + { + LanguageType nInputLang = rEditWin.GetInputLanguage(); + if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) + nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); + } + } + } + SfxItemPool& rPool = *rSet.GetPool(); + SvxScriptSetItem aSetItem( rPool.GetSlotId( nWhich ), rPool ); + aSetItem.GetItemSet().Put( *pFntCoreSet, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); + if( pI ) + rSet.Put( *pI, nWhich ); + else + rSet.InvalidateItem( nWhich ); + //set input context of the SwEditWin according to the selected font and script type + if(RES_CHRATR_FONT == nWhich) + { + Font aFont; + if(pI && pI->ISA(SvxFontItem)) + { + aFont.SetName( ((const SvxFontItem*)pI)->GetFamilyName()); + aFont.SetStyleName(((const SvxFontItem*)pI)->GetStyleName()); + aFont.SetFamily(((const SvxFontItem*)pI)->GetFamily()); + aFont.SetPitch(((const SvxFontItem*)pI)->GetPitch()); + aFont.SetCharSet(((const SvxFontItem*)pI)->GetCharSet()); + } + + BOOL bVertical = rSh.IsInVerticalText(); + aFont.SetOrientation(bVertical ? 2700 : 0); + aFont.SetVertical(bVertical); + GetView().GetEditWin().SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT | + INPUTCONTEXT_EXTTEXTINPUT ) ); + } + } + break; + + default: + if( bFirst ) + { + rSh.GetCurAttr( rSet ); + bFirst = FALSE; + } + } + nWhich = aIter.NextWhich(); + } + delete pFntCoreSet; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwBaseShell::GetBckColState(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + int nSelType = rSh.GetSelectionType(); + +// if ( nSelType & nsSelectionType::SEL_GRF || + if( nSelType & nsSelectionType::SEL_OLE ) + { + rSet.DisableItem( SID_BACKGROUND_COLOR ); + return; + } + + if ( nSelType & nsSelectionType::SEL_FRM ) + { + BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + if (bParentCntProt) + { + rSet.DisableItem( SID_BACKGROUND_COLOR ); + return; + } + } + + SvxBrushItem aBrushItem( RES_BACKGROUND ); + + if( nsSelectionType::SEL_TBL_CELLS & nSelType ) + rSh.GetBoxBackground( aBrushItem ); + else + { + SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND); + if( nSelType & nsSelectionType::SEL_GRF || nsSelectionType::SEL_FRM & nSelType ) + rSh.GetFlyFrmAttr( aCoreSet ); + else + rSh.GetCurAttr( aCoreSet ); + aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND); + } + + while ( nWhich ) + { + switch(nWhich) + { + case SID_BACKGROUND_COLOR : + { + SvxColorItem aColorItem(aBrushItem.GetColor(), SID_BACKGROUND_COLOR); + rSet.Put( aColorItem, SID_BACKGROUND_COLOR ); + } + break; + case SID_ATTR_BRUSH: + case RES_BACKGROUND: + rSet.Put( aBrushItem, GetPool().GetWhich(nWhich) ); + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwBaseShell::ExecBckCol(SfxRequest& rReq) +{ + SwWrtShell &rSh = GetShell(); + int nSelType = rSh.GetSelectionType(); + if ( nSelType & nsSelectionType::SEL_OLE ) + { + return; + } + + const SfxItemSet* pArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + if( !pArgs && nSlot != SID_BACKGROUND_COLOR) + return ; + + SvxBrushItem aBrushItem( RES_BACKGROUND ); + + if( nsSelectionType::SEL_TBL_CELLS & nSelType ) + { + rSh.GetBoxBackground( aBrushItem ); + } + else + { + SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND); + if( (nsSelectionType::SEL_FRM & nSelType) || (nsSelectionType::SEL_GRF & nSelType) ) + rSh.GetFlyFrmAttr( aCoreSet ); + else + rSh.GetCurAttr( aCoreSet ); + aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND); + } + +// BOOL bMsgOk = FALSE; + + switch (nSlot) + { + // RES_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs + // gesetzt werden: + case SID_BACKGROUND_COLOR: + { + aBrushItem.SetGraphicPos(GPOS_NONE); + + //Brush &rBrush = aBrushItem.GetBrush(); + if(pArgs) + { + const SvxColorItem& rNewColorItem = (const SvxColorItem&) + pArgs->Get(SID_BACKGROUND_COLOR); + const Color& rNewColor = rNewColorItem.GetValue(); + aBrushItem.SetColor( rNewColor ); + GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem); + } + else + { + aBrushItem.SetColor( COL_TRANSPARENT ); + rReq.AppendItem( SvxColorItem( Color( COL_TRANSPARENT ), nSlot ) ); + } + } + break; + + case SID_ATTR_BRUSH: + case RES_BACKGROUND: + { + const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&) + pArgs->Get( GetPool().GetWhich(nSlot) ); + aBrushItem = rNewBrushItem; + } + break; + default: +// bMsgOk = FALSE; + rReq.Ignore(); + DBG_ERROR( "Unbekannte Message bei ExecuteAttr!" ); + return; + } + + if( nsSelectionType::SEL_TBL_CELLS & nSelType ) + { + rSh.SetBoxBackground( aBrushItem ); + } + else if( (nsSelectionType::SEL_FRM & nSelType) || + (nsSelectionType::SEL_GRF & nSelType) ) + { + SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND); + aCoreSet.Put( aBrushItem ); + // Vorlagen-AutoUpdate + SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); + if(pFmt && pFmt->IsAutoUpdateFmt()) + rSh.AutoUpdateFrame( pFmt, aCoreSet); + else + rSh.SetFlyFrmAttr( aCoreSet ); + } + else + { + SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl(); + if( pColl && pColl->IsAutoUpdateFmt()) + { + SfxItemSet aSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND ); + aSet.Put(aBrushItem); + rSh.AutoUpdatePara( pColl, aSet); + } + else + rSh.SetAttr( aBrushItem ); + } + + rReq.Done(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwBaseShell::GetBorderState(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + // Tabellenzelle(n) selektiert? + BOOL bPrepare = TRUE; + BOOL bTableMode = rSh.IsTableMode(); + if ( bTableMode ) + { + SfxItemSet aCoreSet( GetPool(), + RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 ); + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + aCoreSet.Put( aBoxInfo ); + rSh.GetTabBorders( aCoreSet ); + rSet.Put( aCoreSet ); + } + else if ( rSh.IsFrmSelected() ) + { + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + rSet.Put( aMgr.GetAttrSet() ); + bPrepare = FALSE; + } + else + // Umrandungsattribute ganz normal ueber Shell holen + rSh.GetCurAttr( rSet ); + if ( bPrepare ) + ::PrepareBoxInfo( rSet, rSh ); + // switch the border toolbox controller mode + rSet.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE, !bTableMode )); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwBaseShell::ExecDlg(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + Window *pMDI = &GetView().GetViewFrame()->GetWindow(); + //Damit aus dem Basic keine Dialoge fuer Hintergrund-Views aufgerufen werden: + BOOL bBackground = (&GetView() != GetActiveView()); + const SfxPoolItem* pItem = 0; + const SfxItemSet* pArgs = rReq.GetArgs(); + + USHORT nSlot = rReq.GetSlot(); + const SfxItemSet* pOutSet = 0; + bool bDone = false; + if(pArgs) + pArgs->GetItemState( GetPool().GetWhich(nSlot), FALSE, &pItem ); + + switch ( nSlot ) + { + case FN_FORMAT_PAGE_COLUMN_DLG: + case FN_FORMAT_PAGE_DLG: + { + if( !bBackground ) + { + const USHORT nCurIdx = rSh.GetCurPageDesc(); + const SwPageDesc& rPageDesc = rSh.GetPageDesc( nCurIdx ); + //temp. View, weil die Shell nach dem Dialog nicht mehr gueltig sein muss + //z.B. Kopfzeile ausschalten + SwView& rTempView = GetView(); + rTempView.GetDocShell()->FormatPage(rPageDesc.GetName(), + nSlot == FN_FORMAT_PAGE_COLUMN_DLG, + &rSh ); + rTempView.InvalidateRulerPos(); + } + } + break; + case FN_FORMAT_BORDER_DLG: + { + SfxItemSet aSet( rSh.GetAttrPool(), + RES_BOX , RES_SHADOW, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + 0 ); + SfxAbstractDialog * pDlg = 0; + // Tabellenzelle(n) selektiert? + if ( rSh.IsTableMode() ) + { + // Umrandungattribute Get/SetTabBorders() setzen + ::PrepareBoxInfo( aSet, rSh ); + rSh.GetTabBorders( aSet ); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() == RET_OK ) + { + rSh.SetTabBorders( *pDlg->GetOutputItemSet() ); + pOutSet = pDlg->GetOutputItemSet(); + } + } + else if ( rSh.IsFrmSelected() ) + { + // Umrandungsattribute ueber Frame-Manager setzen + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + aSet.Put( aMgr.GetAttrSet() ); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() == RET_OK ) + { + aMgr.SetAttrSet( *pDlg->GetOutputItemSet() ); + aMgr.UpdateFlyFrm(); + pOutSet = pDlg->GetOutputItemSet(); + } + } + else + { + // Umrandungsattribute ganz normal ueber Shell setzen + rSh.GetCurAttr( aSet ); + ::PrepareBoxInfo( aSet, rSh ); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() == RET_OK ) + { + rSh.SetAttr( *pDlg->GetOutputItemSet() ); + pOutSet = pDlg->GetOutputItemSet(); + } + } + if(pOutSet) + { + rReq.Done(*pOutSet); + bDone = true; + } + delete pDlg; + } + break; + case FN_FORMAT_BACKGROUND_DLG: + { + SfxItemSet aSet( rSh.GetAttrPool(), + RES_BACKGROUND, RES_BACKGROUND ); + + SfxAbstractDialog * pDlg = 0; + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + + // Tabellenzelle(n) selektiert? + if ( rSh.IsTableMode() ) + { + //Hintergrundattribute der Tabelle holen und in den Set packen + SvxBrushItem aBrush(RES_BACKGROUND); + rSh.GetBoxBackground( aBrush ); + pDlg = pFact->CreateSfxDialog( pMDI, aSet, + rView.GetViewFrame()->GetFrame().GetFrameInterface(), + RC_SWDLG_BACKGROUND ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + aSet.Put( aBrush ); + if ( pDlg->Execute() == RET_OK ) + { + //aBrush = (SvxBrushItem) pDlg->GetOutputItemSet()->Get( RES_BACKGROUND ); + + rSh.SetBoxBackground( (SvxBrushItem&) + pDlg->GetOutputItemSet()->Get( RES_BACKGROUND )); + pOutSet = pDlg->GetOutputItemSet(); + } + } + else if ( rSh.IsFrmSelected() ) + { + + rSh.GetFlyFrmAttr( aSet ); + + pDlg = pFact->CreateSfxDialog( pMDI, aSet, + rView.GetViewFrame()->GetFrame().GetFrameInterface(), + RC_SWDLG_BACKGROUND ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() == RET_OK ) + { + rSh.SetFlyFrmAttr((SfxItemSet &) *pDlg->GetOutputItemSet() ); + pOutSet = pDlg->GetOutputItemSet(); + } + } + else + { + // Umrandungsattribute ganz normal ueber Shell setzen + rSh.GetCurAttr( aSet ); + + pDlg = pFact->CreateSfxDialog( pMDI, aSet, + rView.GetViewFrame()->GetFrame().GetFrameInterface(), + RC_SWDLG_BACKGROUND ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() == RET_OK ) + { + rSh.SetAttr( *pDlg->GetOutputItemSet() ); + pOutSet = pDlg->GetOutputItemSet(); + } + } + if(pOutSet) + { + rReq.Done(*pOutSet); + bDone = true; + } + delete pDlg; + + } + break; + default:DBG_ERROR("falscher Dispatcher (basesh.cxx)"); + } + if(!bDone) + rReq.Done(); +} + +// ---------------------------------------------------------------------------- + + +SwWrtShell& SwBaseShell::GetShell() +{ + return rView.GetWrtShell(); +} + +// ---------------------------------------------------------------------------- + +SwWrtShell* SwBaseShell::GetShellPtr() +{ + return rView.GetWrtShellPtr(); +} + +// ---------------------------------------------------------------------------- + +void SwBaseShell::InsertTable( SfxRequest& _rRequest ) +{ + const SfxItemSet* pArgs = _rRequest.GetArgs(); + SwWrtShell& rSh = GetShell(); + + if ( !( rSh.GetFrmType( 0, TRUE ) & FRMTYPE_FOOTNOTE ) ) + { + SwView &rTempView = GetView(); // Da GetView() nach Shellwechsel nicht mehr geht + BOOL bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON); + BOOL bCallEndUndo = FALSE; + + if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() && + !rSh.IsTableMode() ) + { + const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); + SwInsertTableOptions aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode); + + rSh.StartUndo(UNDO_INSTABLE); + bCallEndUndo = TRUE; + + BOOL bInserted = rSh.TextToTable( aInsTblOpts, '\t', text::HoriOrientation::FULL ); + rSh.EnterStdMode(); + if (bInserted) + rTempView.AutoCaption(TABLE_CAP); + _rRequest.Done(); + } + else + { + USHORT nCols = 0; + USHORT nRows = 0; + SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 ); + String aTableName, aAutoName; + SwTableAutoFmt* pTAFmt = 0; + + if( pArgs && pArgs->Count() >= 2 ) + { + SFX_REQUEST_ARG( _rRequest, pName, SfxStringItem, FN_INSERT_TABLE, sal_False ); + SFX_REQUEST_ARG( _rRequest, pCols, SfxUInt16Item, SID_ATTR_TABLE_COLUMN, sal_False ); + SFX_REQUEST_ARG( _rRequest, pRows, SfxUInt16Item, SID_ATTR_TABLE_ROW, sal_False ); + SFX_REQUEST_ARG( _rRequest, pFlags, SfxInt32Item, FN_PARAM_1, sal_False ); + SFX_REQUEST_ARG( _rRequest, pAuto, SfxStringItem, FN_PARAM_2, sal_False ); + + if ( pName ) + aTableName = pName->GetValue(); + if ( pCols ) + nCols = pCols->GetValue(); + if ( pRows ) + nRows = pRows->GetValue(); + if ( pAuto ) + { + aAutoName = pAuto->GetValue(); + if ( aAutoName.Len() ) + { + SwTableAutoFmtTbl aTableTbl; + aTableTbl.Load(); + for ( USHORT n=0; n<aTableTbl.Count(); n++ ) + { + if ( aTableTbl[n]->GetName() == aAutoName ) + { + pTAFmt = new SwTableAutoFmt( *aTableTbl[n] ); + break; + } + } + } + } + + if ( pFlags ) + aInsTblOpts.mnInsMode = (USHORT) pFlags->GetValue(); + else + { + const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); + aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode); + } + } + + if( !nCols || !nRows ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractInsTableDlg* pDlg = pFact->CreateInsTableDlg( DLG_INSERT_TABLE, rTempView ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if( RET_OK == pDlg->Execute() ) + { + pDlg->GetValues( aTableName, nRows, nCols, aInsTblOpts, aAutoName, pTAFmt ); + } + else + _rRequest.Ignore(); + delete pDlg; + } + + if( nCols && nRows ) + { + // record before shell change + _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableName ) ); + if ( aAutoName.Len() ) + _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoName ) ); + _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nCols ) ); + _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRows ) ); + _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, (sal_Int32) aInsTblOpts.mnInsMode ) ); + _rRequest.Done(); + + rSh.StartUndo(UNDO_INSTABLE); + bCallEndUndo = TRUE; + + rSh.StartAllAction(); + if( rSh.HasSelection() ) + rSh.DelRight(); + + rSh.InsertTable( aInsTblOpts, nRows, nCols, text::HoriOrientation::FULL, pTAFmt ); + rSh.MoveTable( fnTablePrev, fnTableStart ); + + if( aTableName.Len() && !rSh.GetTblStyle( aTableName ) ) + rSh.GetTableFmt()->SetName( aTableName ); + + rSh.EndAllAction(); + rTempView.AutoCaption(TABLE_CAP); + } + delete pTAFmt; + } + + if( bCallEndUndo ) + { + SwRewriter aRewriter; + + if (rSh.GetTableFmt()) + { + aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE)); + aRewriter.AddRule(UNDO_ARG2, rSh.GetTableFmt()->GetName()); + aRewriter.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE)); + + } + rSh.EndUndo(UNDO_INSTABLE, &aRewriter); // wegen moegl. Shellwechsel + } + } +} + +// ---------------------------------------------------------------------------- + +void SwBaseShell::GetGalleryState( SfxItemSet &rSet ) +{ + SwWrtShell &rSh = GetShell(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + switch ( nWhich ) + { + case SID_GALLERY_BG_BRUSH: + { + int nSel = rSh.GetSelectionType(); + SfxStringListItem aLst( nWhich ); + List *pLst = aLst.GetList(); + nParagraphPos = nGraphicPos = nOlePos = nFramePos = nTablePos = + nTableRowPos = nTableCellPos = nPagePos = + nHeaderPos = nFooterPos = 0; + BYTE nPos = 1; + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_PAGE ), pLst->Count() ); + nPagePos = nPos++; + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + BOOL bHtmlMode = 0 != (nHtmlMode & HTMLMODE_ON); + + if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES)) && + (nSel & nsSelectionType::SEL_TXT) ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_PARAGRAPH ), pLst->Count() ); + nParagraphPos = nPos++; + } + if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_SOME_STYLES)) && + nSel & (nsSelectionType::SEL_TBL|nsSelectionType::SEL_TBL_CELLS) ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE ), pLst->Count() ); + nTablePos = nPos++; + + if(!bHtmlMode) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE_ROW ), pLst->Count() ); + nTableRowPos = nPos++; + } + + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE_CELL), pLst->Count() ); + nTableCellPos = nPos++; + } + if(!bHtmlMode) + { + if ( nSel & nsSelectionType::SEL_FRM ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_FRAME ), pLst->Count() ); + nFramePos = nPos++; + } + if ( nSel & nsSelectionType::SEL_GRF ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_GRAPHIC ), pLst->Count() ); + nGraphicPos = nPos++; + } + if ( nSel & nsSelectionType::SEL_OLE ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_OLE ), pLst->Count() ); + nOlePos = nPos++; + } + const USHORT nType = rSh.GetFrmType(0,TRUE); + if ( nType & FRMTYPE_HEADER ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_HEADER ), pLst->Count() ); + nHeaderPos = nPos++; + } + if ( nType & FRMTYPE_FOOTER ) + { + pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_FOOTER ), pLst->Count() ); + nFooterPos = nPos; + } + } + if ( pLst->Count() ) + rSet.Put( aLst ); + else + rSet.DisableItem( nWhich ); + break; + } + } +} + + +void SwBaseShell::ExecuteGallery(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + rSh.StartAction(); + const SfxItemSet* pArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + switch(nSlot) + { + case SID_GALLERY_BG_BRUSH: + { + int nSel = rSh.GetSelectionType(); + if ( nSel & nsSelectionType::SEL_DRW_TXT ) + break; + + BYTE nPos = (BYTE)((SfxUInt16Item &)pArgs->Get(SID_GALLERY_BG_POS)).GetValue(); + ++nPos; + + SvxBrushItem aBrush( (SvxBrushItem&)pArgs->Get(SID_GALLERY_BG_BRUSH)); + aBrush.SetWhich( RES_BACKGROUND ); + if ( nPos == nParagraphPos ) + rSh.SetAttr( aBrush ); + else if ( nPos == nTablePos ) + rSh.SetTabBackground( aBrush ); + else if ( nPos == nTableRowPos ) + rSh.SetRowBackground( aBrush ); + else if ( nPos == nTableCellPos ) + rSh.SetBoxBackground( aBrush ); + else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos ) + { + SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND); + aCoreSet.Put( aBrush ); + rSh.SetFlyFrmAttr( aCoreSet ); + } + else if ( nPos == nPagePos || nPos == nHeaderPos || nPos == nFooterPos ) + { + USHORT nDesc = rSh.GetCurPageDesc(); + SwPageDesc aDesc( rSh.GetPageDesc( nDesc ) ); + if ( nPos == nPagePos ) + aDesc.GetMaster().SetFmtAttr( aBrush ); + else if ( nPos == nHeaderPos ) + { + SwFmtHeader aHead( aDesc.GetMaster().GetHeader() ); + aHead.GetHeaderFmt()->SetFmtAttr( aBrush ); + aDesc.GetMaster().SetFmtAttr( aHead ); + } + else if ( nPos == nFooterPos ) + { + SwFmtFooter aFoot( aDesc.GetMaster().GetFooter() ); + aFoot.GetFooterFmt()->SetFmtAttr( aBrush ); + aDesc.GetMaster().SetFmtAttr( aFoot ); + } + rSh.ChgPageDesc( nDesc, aDesc ); + } + break; + } + } + rSh.EndAction(); + rReq.Done(); +} + +void SwBaseShell::ExecField( SfxRequest& rReq ) +{ + USHORT nSlot = rReq.GetSlot(); + switch( nSlot ) + { + case FN_CHANGE_DBFIELD: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwChangeDBDlg(GetView(), DLG_CHANGE_DB ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + break; + default: + ASSERT(FALSE, falscher Dispatcher); + } +} + diff --git a/sw/source/ui/shells/beziersh.cxx b/sw/source/ui/shells/beziersh.cxx new file mode 100644 index 000000000000..cc6a3176643f --- /dev/null +++ b/sw/source/ui/shells/beziersh.cxx @@ -0,0 +1,356 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 "cmdid.h" +#include <svx/svdview.hxx> +#include <svl/srchitem.hxx> +#include <svl/eitem.hxx> +#include <svl/whiter.hxx> +#include <svx/svdopath.hxx> +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objface.hxx> + +#include "wrtsh.hxx" +#include "view.hxx" +#include "edtwin.hxx" +#include "helpid.h" +#include "globals.hrc" +#include "drawbase.hxx" +#include "beziersh.hxx" +#include "popup.hrc" +#include "shells.hrc" +#define SwBezierShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" + +#include <unomid.h> + + +SFX_IMPL_INTERFACE(SwBezierShell, SwBaseShell, SW_RES(STR_SHELLNAME_BEZIER)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_BEZIER_TOOLBOX)); +} + +TYPEINIT1(SwBezierShell,SwBaseShell) + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +SwBezierShell::SwBezierShell(SwView &_rView): + SwBaseShell( _rView ) +{ + SetName(C2S("Bezier")); + SetHelpId(SW_BEZIERSHELL); + + SwWrtShell *pSh = &GetShell(); + SdrView* pSdrView = pSh->GetDrawView(); + pSdrView->SetEliminatePolyPointLimitAngle(1500L); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwBezierShell::Execute(SfxRequest &rReq) +{ + SwWrtShell *pSh = &GetShell(); + SdrView* pSdrView = pSh->GetDrawView(); + const SfxItemSet *pArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + BOOL bChanged = pSdrView->GetModel()->IsChanged(); + pSdrView->GetModel()->SetChanged(FALSE); + const SfxPoolItem* pItem; + if(pArgs) + pArgs->GetItemState(nSlotId, FALSE, &pItem); + + switch (nSlotId) + { + case SID_DELETE: + case FN_BACKSPACE: + if (pSh->IsObjSelected()) + { + if (pSdrView->HasMarkedPoints()) + pSh->GetView().GetViewFrame()->GetDispatcher()->Execute(SID_BEZIER_DELETE, FALSE); + else + { + pSh->DelSelectedObj(); + if (pSh->IsSelFrmMode()) + { + pSh->LeaveSelFrmMode(); + pSh->NoEdit(); + } + GetView().AttrChangedNotify(pSh); // ggf Shellwechsel... + } + } + break; + + case FN_ESCAPE: + if (pSdrView->HasMarkedPoints()) + pSdrView->UnmarkAllPoints(); + else + { + if ( pSh->IsDrawCreate() ) + { + GetView().GetDrawFuncPtr()->BreakCreate(); + GetView().AttrChangedNotify(pSh); // ggf Shellwechsel... + } + else if ( pSh->HasSelection() || GetView().IsDrawMode() ) + { + GetView().LeaveDrawCreate(); + pSh->EnterStdMode(); + GetView().AttrChangedNotify(pSh); // ggf Shellwechsel... + } + } + break; + + case SID_BEZIER_MOVE: + case SID_BEZIER_INSERT: + { + GetView().GetEditWin().SetBezierMode(nSlotId); + static USHORT __READONLY_DATA aInva[] = + { + SID_BEZIER_INSERT, + SID_BEZIER_MOVE, + 0 + }; + GetView().GetViewFrame()->GetBindings().Invalidate(aInva); + } + break; + + case SID_BEZIER_DELETE: + case SID_BEZIER_CUTLINE: + case SID_BEZIER_CONVERT: + case SID_BEZIER_EDGE: + case SID_BEZIER_SMOOTH: + case SID_BEZIER_SYMMTR: + case SID_BEZIER_CLOSE: + case SID_BEZIER_ELIMINATE_POINTS: + { + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + + if (rMarkList.GetMark(0) && !pSdrView->IsAction()) + { + switch (nSlotId) + { + case SID_BEZIER_DELETE: + pSdrView->DeleteMarkedPoints(); + break; + + case SID_BEZIER_CUTLINE: + { + pSdrView->RipUpAtMarkedPoints(); + pSh->CheckUnboundObjects(); + } + break; + + case SID_BEZIER_CONVERT: + { + pSdrView->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE); + break; + } + + case SID_BEZIER_EDGE: + case SID_BEZIER_SMOOTH: + case SID_BEZIER_SYMMTR: + { + SdrPathSmoothKind eKind = SDRPATHSMOOTH_ASYMMETRIC; + + switch (nSlotId) + { + case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break; + case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break; + case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break; + } + + SdrPathSmoothKind eSmooth = pSdrView->GetMarkedPointsSmooth(); + if (eKind != eSmooth) + { + pSdrView->SetMarkedPointsSmooth(eKind); + + static USHORT __READONLY_DATA aInva[] = + { + SID_BEZIER_SMOOTH, + SID_BEZIER_EDGE, + SID_BEZIER_SYMMTR, + 0 + }; + GetView().GetViewFrame()->GetBindings().Invalidate(aInva); + } + break; + } + + case SID_BEZIER_CLOSE: + { + SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj(); + pSdrView->UnmarkAllPoints(); + // Size aDist(GetView().GetEditWin().PixelToLogic(Size(8,8))); + pPathObj->ToggleClosed(); // aDist.Width()); + break; + } + + case SID_BEZIER_ELIMINATE_POINTS: + pSdrView->SetEliminatePolyPoints(!pSdrView->IsEliminatePolyPoints()); + break; + } + } + } + break; + + default: + break; + } + + if (pSdrView->GetModel()->IsChanged()) + GetShell().SetModified(); + else if (bChanged) + pSdrView->GetModel()->SetChanged(TRUE); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwBezierShell::GetState(SfxItemSet &rSet) +{ + SdrView* pSdrView = GetShell().GetDrawView(); + + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + while( nWhich ) + { + switch( nWhich ) + { + case SID_BEZIER_MOVE: + case SID_BEZIER_INSERT: + { + USHORT nEditMode = GetView().GetEditWin().GetBezierMode(); + + rSet.Put(SfxBoolItem(nWhich, nEditMode == nWhich)); + } + break; + + case SID_BEZIER_CUTLINE: + if (!pSdrView->IsRipUpAtMarkedPointsPossible()) + { + rSet.DisableItem(SID_BEZIER_CUTLINE); + } + break; + + case SID_BEZIER_DELETE: + if (!pSdrView->IsDeleteMarkedPointsPossible()) + { + rSet.DisableItem(SID_BEZIER_DELETE); + } + break; + + case SID_BEZIER_CONVERT: + if (!pSdrView->IsSetMarkedSegmentsKindPossible()) + { + rSet.DisableItem(SID_BEZIER_CONVERT); + } + else + { + SdrPathSegmentKind eSegm = pSdrView->GetMarkedSegmentsKind(); + switch (eSegm) + { + case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break; + case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,FALSE)); break; // Button reingedrueckt = Kurve + case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,TRUE)); break; + default:; //prevent warning + } + } + break; + + case SID_BEZIER_EDGE: + case SID_BEZIER_SMOOTH: + case SID_BEZIER_SYMMTR: + if (!pSdrView->IsSetMarkedPointsSmoothPossible()) + rSet.DisableItem(nWhich); + else + { + SdrPathSmoothKind eSmooth = pSdrView->GetMarkedPointsSmooth(); + BOOL bEnable = FALSE; + switch (eSmooth) + { + case SDRPATHSMOOTH_DONTCARE : + break; + case SDRPATHSMOOTH_ANGULAR : + bEnable = nWhich == SID_BEZIER_EDGE; + break; + case SDRPATHSMOOTH_ASYMMETRIC: + bEnable = nWhich == SID_BEZIER_SMOOTH; + break; + case SDRPATHSMOOTH_SYMMETRIC : + bEnable = nWhich == SID_BEZIER_SYMMTR; + break; + } + rSet.Put(SfxBoolItem(nWhich, bEnable)); + } + break; + + case SID_BEZIER_CLOSE: + if (!pSdrView->IsOpenCloseMarkedObjectsPossible()) + { + rSet.DisableItem(SID_BEZIER_CLOSE); + } + else + { + SdrObjClosedKind eClose = pSdrView->GetMarkedObjectsClosedState(); + switch (eClose) + { + case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break; + case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,FALSE)); break; + case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,TRUE)); break; + default:; //prevent warning + } + } + break; + + case SID_BEZIER_ELIMINATE_POINTS: + rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, pSdrView->IsEliminatePolyPoints())); + break; + + default: + break; + } + nWhich = aIter.NextWhich(); + } +} + + + diff --git a/sw/source/ui/shells/drawdlg.cxx b/sw/source/ui/shells/drawdlg.cxx new file mode 100644 index 000000000000..56b783a25711 --- /dev/null +++ b/sw/source/ui/shells/drawdlg.cxx @@ -0,0 +1,259 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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" + + + + + +#ifndef _SVX_SVXIDS_HRC //autogen +#include <svx/svxids.hrc> +#endif +#ifndef _MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <svx/svdview.hxx> +#include <svx/tabarea.hxx> +#include <svx/tabline.hxx> +#include <svx/drawitem.hxx> + +#include <svx/xtable.hxx> +#include "view.hxx" +#include "wrtsh.hxx" +#include "docsh.hxx" +#include "cmdid.h" + +#include "drawsh.hxx" +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) +{ + SwWrtShell* pSh = &GetShell(); + SdrView* pView = pSh->GetDrawView(); + SdrModel* pDoc = pView->GetModel(); + BOOL bChanged = pDoc->IsChanged(); + pDoc->SetChanged(FALSE); + + SfxItemSet aNewAttr( pDoc->GetItemPool() ); + pView->GetAttributes( aNewAttr ); + + GetView().NoRotate(); + + switch (rReq.GetSlot()) + { + case FN_DRAWTEXT_ATTR_DLG: + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView ); + USHORT nResult = pDlg->Execute(); + + if (nResult == RET_OK) + { + if (pView->AreObjectsMarked()) + { + pSh->StartAction(); + pView->SetAttributes(*pDlg->GetOutputItemSet()); + rReq.Done(*(pDlg->GetOutputItemSet())); + pSh->EndAction(); + } + } + + delete( pDlg ); + } + } + break; + + case SID_ATTRIBUTES_AREA: + { + BOOL bHasMarked = pView->AreObjectsMarked(); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); + AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL, + &aNewAttr, + pDoc, + pView); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + const SvxColorTableItem* pColorItem = (const SvxColorTableItem*) + GetView().GetDocShell()->GetItem(SID_COLOR_TABLE); + if(pColorItem->GetColorTable() == XColorTable::GetStdColorTable()) + pDlg->DontDeleteColorTable(); + if (pDlg->Execute() == RET_OK) + { + pSh->StartAction(); + if (bHasMarked) + pView->SetAttributes(*pDlg->GetOutputItemSet()); + else + pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), FALSE); + pSh->EndAction(); + + static USHORT __READONLY_DATA aInval[] = + { + SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, 0 + }; + SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); + rBnd.Invalidate(aInval); + rBnd.Update(SID_ATTR_FILL_STYLE); + rBnd.Update(SID_ATTR_FILL_COLOR); + } + delete pDlg; + } + break; + + case SID_ATTRIBUTES_LINE: + { + BOOL bHasMarked = pView->AreObjectsMarked(); + + const SdrObject* pObj = NULL; + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); + SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL, + &aNewAttr, + pDoc, + pObj, + bHasMarked); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if (pDlg->Execute() == RET_OK) + { + pSh->StartAction(); + if(bHasMarked) + pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), FALSE); + else + pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), FALSE); + pSh->EndAction(); + + static USHORT __READONLY_DATA aInval[] = + { + SID_ATTR_LINE_STYLE, SID_ATTR_LINE_WIDTH, + SID_ATTR_LINE_COLOR, 0 + }; + + GetView().GetViewFrame()->GetBindings().Invalidate(aInval); + } + delete pDlg; + } + break; + + default: + break; + } + + + if (pDoc->IsChanged()) + GetShell().SetModified(); + else + if (bChanged) + pDoc->SetChanged(TRUE); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq) +{ + SwWrtShell* pSh = &GetShell(); + SdrView* pView = pSh->GetDrawView(); + const SfxItemSet* pArgs = rReq.GetArgs(); + BOOL bChanged = pView->GetModel()->IsChanged(); + pView->GetModel()->SetChanged(FALSE); + + GetView().NoRotate(); + + if (pArgs) + { + if(pView->AreObjectsMarked()) + pView->SetAttrToMarked(*rReq.GetArgs(), FALSE); + else + pView->SetDefaultAttr(*rReq.GetArgs(), FALSE); + } + else + { + SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher(); + switch (rReq.GetSlot()) + { + case SID_ATTR_FILL_STYLE: + case SID_ATTR_FILL_COLOR: + case SID_ATTR_FILL_GRADIENT: + case SID_ATTR_FILL_HATCH: + case SID_ATTR_FILL_BITMAP: + pDis->Execute(SID_ATTRIBUTES_AREA, FALSE); + break; + case SID_ATTR_LINE_STYLE: + case SID_ATTR_LINE_DASH: + case SID_ATTR_LINE_WIDTH: + case SID_ATTR_LINE_COLOR: + pDis->Execute(SID_ATTRIBUTES_LINE, FALSE); + break; + } + } + if (pView->GetModel()->IsChanged()) + GetShell().SetModified(); + else + if (bChanged) + pView->GetModel()->SetChanged(TRUE); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet) +{ + SdrView* pSdrView = GetShell().GetDrawView(); + + if (pSdrView->AreObjectsMarked()) + { + BOOL bDisable = Disable( rSet ); + + if( !bDisable ) + pSdrView->GetAttributes( rSet ); + } + else + rSet.Put(pSdrView->GetDefaultAttr()); +} + + + diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx new file mode 100644 index 000000000000..eb571036e322 --- /dev/null +++ b/sw/source/ui/shells/drawsh.cxx @@ -0,0 +1,497 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <tools/shl.hxx> +#include <svx/svdview.hxx> +#include <svx/svdotext.hxx> +#include <svl/whiter.hxx> +#include <svx/fontwork.hxx> +#include <sfx2/request.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/objface.hxx> +#include <svl/itemiter.hxx> +#include <svl/srchitem.hxx> +#include <svx/xftsfit.hxx> +#include <svx/extrusionbar.hxx> +#include <svx/fontworkbar.hxx> +#include <svx/tbxcustomshapes.hxx> +#include <uitool.hxx> +#include <wview.hxx> +#include <swmodule.hxx> +#include <swwait.hxx> +#include <docstat.hxx> +#include <IDocumentStatistics.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + +#include <svx/xtable.hxx> + +#include "swundo.hxx" +#include "wrtsh.hxx" +#include "cmdid.h" +#include "globals.hrc" +#include "helpid.h" +#include "popup.hrc" +#include "shells.hrc" +#include "drwbassh.hxx" +#include "drawsh.hxx" + +#define SwDrawShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" +#include "swabstdlg.hxx" //CHINA001 +#include "misc.hrc" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TOOLBOX)); + SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId()); +} + +TYPEINIT1(SwDrawShell,SwDrawBaseShell) + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwDrawShell::Execute(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + SdrView *pSdrView = rSh.GetDrawView(); + const SfxItemSet *pArgs = rReq.GetArgs(); + SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); + USHORT nSlotId = rReq.GetSlot(); + BOOL bChanged = pSdrView->GetModel()->IsChanged(); + + pSdrView->GetModel()->SetChanged(FALSE); + + const SfxPoolItem* pItem; + if(pArgs) + pArgs->GetItemState(nSlotId, FALSE, &pItem); + + BOOL bMirror = TRUE; + + switch (nSlotId) + { + case SID_OBJECT_ROTATE: + if (rSh.IsObjSelected() && pSdrView->IsRotateAllowed()) + { + if (GetView().IsDrawRotate()) + rSh.SetDragMode(SDRDRAG_MOVE); + else + rSh.SetDragMode(SDRDRAG_ROTATE); + + GetView().FlipDrawRotate(); + } + break; + + case SID_BEZIER_EDIT: + if (GetView().IsDrawRotate()) + { + rSh.SetDragMode(SDRDRAG_MOVE); + GetView().FlipDrawRotate(); + } + GetView().FlipDrawSelMode(); + pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode()); + GetView().AttrChangedNotify(&rSh); // Shellwechsel... + break; + + case SID_OBJECT_HELL: + if (rSh.IsObjSelected()) + { + rSh.StartUndo( UNDO_START ); + SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP); + rSh.SelectionToHell(); + rSh.EndUndo( UNDO_END ); + rBnd.Invalidate(SID_OBJECT_HEAVEN); + } + break; + + case SID_OBJECT_HEAVEN: + if (rSh.IsObjSelected()) + { + rSh.StartUndo( UNDO_START ); + SetWrapMode(FN_FRAME_WRAPTHRU); + rSh.SelectionToHeaven(); + rSh.EndUndo( UNDO_END ); + rBnd.Invalidate(SID_OBJECT_HELL); + } + break; + + case FN_TOOL_HIERARCHIE: + if (rSh.IsObjSelected()) + { + rSh.StartUndo( UNDO_START ); + if (rSh.GetLayerId() == 0) + { + SetWrapMode(FN_FRAME_WRAPTHRU); + rSh.SelectionToHeaven(); + } + else + { + SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP); + rSh.SelectionToHell(); + } + rSh.EndUndo( UNDO_END ); + rBnd.Invalidate( SID_OBJECT_HELL ); + rBnd.Invalidate( SID_OBJECT_HEAVEN ); + } + break; + + case FN_FLIP_HORZ_GRAFIC: + bMirror = FALSE; + /* no break */ + case FN_FLIP_VERT_GRAFIC: + rSh.MirrorSelection( bMirror ); + break; + + case SID_FONTWORK: + { + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) ); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pArgs) + { + pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), + ((const SfxBoolItem&)(pArgs->Get(SID_FONTWORK))).GetValue()); + } + else + pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); + pVFrame->GetBindings().Invalidate(SID_FONTWORK); + } + break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; + case SID_EXTRUSION_TOOGLE: + case SID_EXTRUSION_TILT_DOWN: + case SID_EXTRUSION_TILT_UP: + case SID_EXTRUSION_TILT_LEFT: + case SID_EXTRUSION_TILT_RIGHT: + case SID_EXTRUSION_3D_COLOR: + case SID_EXTRUSION_DEPTH: + case SID_EXTRUSION_DIRECTION: + case SID_EXTRUSION_PROJECTION: + case SID_EXTRUSION_LIGHTING_DIRECTION: + case SID_EXTRUSION_LIGHTING_INTENSITY: + case SID_EXTRUSION_SURFACE: + case SID_EXTRUSION_DEPTH_FLOATER: + case SID_EXTRUSION_DIRECTION_FLOATER: + case SID_EXTRUSION_LIGHTING_FLOATER: + case SID_EXTRUSION_SURFACE_FLOATER: + case SID_EXTRUSION_DEPTH_DIALOG: + svx::ExtrusionBar::execute( pSdrView, rReq, rBnd ); + rReq.Ignore (); + break; + + case SID_FONTWORK_SHAPE: + case SID_FONTWORK_SHAPE_TYPE: + case SID_FONTWORK_ALIGNMENT: + case SID_FONTWORK_SAME_LETTER_HEIGHTS: + case SID_FONTWORK_CHARACTER_SPACING: + case SID_FONTWORK_KERN_CHARACTER_PAIRS: + case SID_FONTWORK_CHARACTER_SPACING_FLOATER: + case SID_FONTWORK_ALIGNMENT_FLOATER: + case SID_FONTWORK_CHARACTER_SPACING_DIALOG: + svx::FontworkBar::execute( pSdrView, rReq, rBnd ); + rReq.Ignore (); + break; + + default: + DBG_ASSERT(!this, "falscher Dispatcher"); + return; + } + if (pSdrView->GetModel()->IsChanged()) + rSh.SetModified(); + else if (bChanged) + pSdrView->GetModel()->SetChanged(TRUE); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +void SwDrawShell::GetState(SfxItemSet& rSet) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + BOOL bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT); + + if (!bProtected) // Im Parent nachsehen + bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + + while( nWhich ) + { + switch( nWhich ) + { + case SID_OBJECT_HELL: + if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 0 || bProtected ) + rSet.DisableItem( nWhich ); + break; + + case SID_OBJECT_HEAVEN: + if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 1 || bProtected ) + rSet.DisableItem( nWhich ); + break; + + case FN_TOOL_HIERARCHIE: + if ( !rSh.IsObjSelected() || bProtected ) + rSet.DisableItem( nWhich ); + break; + + case SID_OBJECT_ROTATE: + { + const BOOL bIsRotate = GetView().IsDrawRotate(); + if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected ) + rSet.DisableItem( nWhich ); + else + rSet.Put( SfxBoolItem( nWhich, bIsRotate ) ); + } + break; + + case SID_BEZIER_EDIT: + if (!Disable(rSet, nWhich)) + rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode())); + break; + + case FN_FLIP_HORZ_GRAFIC: + if ( !pSdrView->IsMirrorAllowed() || bProtected ) + rSet.DisableItem( nWhich ); + break; + + case FN_FLIP_VERT_GRAFIC: + if ( !pSdrView->IsMirrorAllowed() || bProtected ) + rSet.DisableItem( nWhich ); + break; + + case SID_FONTWORK: + { + if (bProtected) + rSet.DisableItem( nWhich ); + else + { + const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId))); + } + } + break; + } + nWhich = aIter.NextWhich(); + } + svx::ExtrusionBar::getState( pSdrView, rSet ); + svx::FontworkBar::getState( pSdrView, rSet ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +SwDrawShell::SwDrawShell(SwView &_rView) : + SwDrawBaseShell(_rView) +{ + SetHelpId(SW_DRAWSHELL); + SetName(String::CreateFromAscii("Draw")); +} + +/************************************************************************* +|* +|* SfxRequests fuer FontWork bearbeiten +|* +\************************************************************************/ + + + +void SwDrawShell::ExecFormText(SfxRequest& rReq) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pDrView = rSh.GetDrawView(); + BOOL bChanged = pDrView->GetModel()->IsChanged(); + pDrView->GetModel()->SetChanged(FALSE); + + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + + if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) + { + const SfxItemSet& rSet = *rReq.GetArgs(); + const SfxPoolItem* pItem; + + if ( pDrView->IsTextEdit() ) + { + pDrView->SdrEndTextEdit( TRUE ); + GetView().AttrChangedNotify(&rSh); + } + + if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem) == + SFX_ITEM_SET && + ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE ) + { + + const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + + SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)(GetView().GetViewFrame()-> + GetChildWindow(nId)->GetWindow()); + + pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(), + rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(), + ((const XFormTextStdFormItem*) pItem)-> + GetValue()); + + } + else + pDrView->SetAttributes(rSet); + } + if (pDrView->GetModel()->IsChanged()) + rSh.SetModified(); + else + if (bChanged) + pDrView->GetModel()->SetChanged(TRUE); +} + +/************************************************************************* +|* +|* Statuswerte fuer FontWork zurueckgeben +|* +\************************************************************************/ + + + +void SwDrawShell::GetFormTextState(SfxItemSet& rSet) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pDrView = rSh.GetDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + const SdrObject* pObj = NULL; + SvxFontWorkDialog* pDlg = NULL; + + const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if ( pVFrame->HasChildWindow(nId) ) + pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow()); + + if ( rMarkList.GetMarkCount() == 1 ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + if ( pObj == NULL || !pObj->ISA(SdrTextObj) || + !((SdrTextObj*) pObj)->HasText() ) + { +#define XATTR_ANZ 12 + static const USHORT nXAttr[ XATTR_ANZ ] = + { + XATTR_FORMTXTSTYLE, XATTR_FORMTXTADJUST, XATTR_FORMTXTDISTANCE, + XATTR_FORMTXTSTART, XATTR_FORMTXTMIRROR, XATTR_FORMTXTSTDFORM, + XATTR_FORMTXTHIDEFORM, XATTR_FORMTXTOUTLINE, XATTR_FORMTXTSHADOW, + XATTR_FORMTXTSHDWCOLOR, XATTR_FORMTXTSHDWXVAL, XATTR_FORMTXTSHDWYVAL + }; + for( USHORT i = 0; i < XATTR_ANZ; ) + rSet.DisableItem( nXAttr[ i++ ] ); + } + else + { + if ( pDlg ) + pDlg->SetColorTable(XColorTable::GetStdColorTable()); + + pDrView->GetAttributes( rSet ); + } +} + + + + diff --git a/sw/source/ui/shells/drformsh.cxx b/sw/source/ui/shells/drformsh.cxx new file mode 100644 index 000000000000..13b1f1059b8d --- /dev/null +++ b/sw/source/ui/shells/drformsh.cxx @@ -0,0 +1,276 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/svdview.hxx> +#include <svl/whiter.hxx> +#include <sfx2/request.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/app.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/srchitem.hxx> +#include <svx/fmglob.hxx> +#include <svx/svdouno.hxx> +#include <com/sun/star/form/FormButtonType.hpp> +#include <svx/htmlmode.hxx> +#include <tools/urlobj.hxx> + +#include "viewopt.hxx" +#include "swmodule.hxx" +#include "wrtsh.hxx" +#include "cmdid.h" +#include "globals.hrc" +#include "helpid.h" +#include "popup.hrc" +#include "shells.hrc" +#include "drwbassh.hxx" +#include "drformsh.hxx" +#include <svl/urihelper.hxx> +#include <view.hxx> +#include <sfx2/docfile.hxx> +#include <docsh.hxx> + +#define SwDrawFormShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" + +#include <unomid.h> + + +using namespace ::com::sun::star; +using ::rtl::OUString; + +SFX_IMPL_INTERFACE(SwDrawFormShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAWFORM)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAWFORM_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX)); +} + + +TYPEINIT1(SwDrawFormShell, SwDrawBaseShell) + + +void SwDrawFormShell::Execute(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + const SfxPoolItem* pItem = 0; + const SfxItemSet *pArgs = rReq.GetArgs(); + + switch ( rReq.GetSlot() ) + { + case SID_HYPERLINK_SETLINK: + { + if(pArgs) + pArgs->GetItemState(SID_HYPERLINK_SETLINK, sal_False, &pItem); + if(pItem) + { + SdrView *pSdrView = rSh.GetDrawView(); + const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; + bool bConvertToText = rHLinkItem.GetInsertMode() == HLINK_DEFAULT || + rHLinkItem.GetInsertMode() == HLINK_FIELD; + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if (rMarkList.GetMark(0)) + { + SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj()); + if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) + { + if(bConvertToText) + { + //remove object -> results in destruction of this! + SwView& rTempView = GetView(); + rTempView.GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SFX_CALLMODE_SYNCHRON ); + rTempView.StopShellTimer(); + //issue a new command to insert the link + rTempView.GetViewFrame()->GetDispatcher()->Execute( + SID_HYPERLINK_SETLINK, SFX_CALLMODE_ASYNCHRON, &rHLinkItem, 0); + } + else + { + uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel(); + + ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); + if( !xControlModel.is() ) + return; + + uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY); + + // Darf man eine URL an dem Objekt setzen? + OUString sTargetURL( C2U( "TargetURL" )); + uno::Reference< beans::XPropertySetInfo > xPropInfoSet = xPropSet->getPropertySetInfo(); + if( xPropInfoSet->hasPropertyByName( sTargetURL )) + { + beans::Property aProp = xPropInfoSet->getPropertyByName( sTargetURL ); + if( aProp.Name.getLength() ) + { + uno::Any aTmp; + // Ja! + ::rtl::OUString sLabel(C2U("Label")); + if( xPropInfoSet->hasPropertyByName(sLabel) ) + { + aTmp <<= OUString(rHLinkItem.GetName()); + xPropSet->setPropertyValue(sLabel, aTmp ); + } + + SfxMedium* pMedium = GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + aTmp <<= OUString(URIHelper::SmartRel2Abs(aAbs, rHLinkItem.GetURL())); + xPropSet->setPropertyValue( sTargetURL, aTmp ); + + if( rHLinkItem.GetTargetFrame().Len() ) + { + aTmp <<= OUString(rHLinkItem.GetTargetFrame()); + xPropSet->setPropertyValue( C2U("TargetFrame"), aTmp ); + } + + + form::FormButtonType eButtonType = form::FormButtonType_URL; + aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0)); + xPropSet->setPropertyValue( C2U("ButtonType"), aTmp ); + } + } + } + } + } + } + } + break; + + default: + DBG_ASSERT(!this, "falscher Dispatcher"); + return; + } +} + +void SwDrawFormShell::GetState(SfxItemSet& rSet) +{ + SwWrtShell &rSh = GetShell(); + SfxWhichIter aIter( rSet ); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while( nWhich ) + { + switch( nWhich ) + { + case SID_HYPERLINK_GETLINK: + { + SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + SvxHyperlinkItem aHLinkItem; + if (rMarkList.GetMark(0)) + { + SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj()); + if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) + { + uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel(); + + ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); + if( !xControlModel.is() ) + return; + + uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY); + + uno::Any aTmp; + uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); + if(xInfo->hasPropertyByName(C2U("ButtonType" ))) + { + form::FormButtonType eButtonType = form::FormButtonType_URL; + aTmp = xPropSet->getPropertyValue( C2U("ButtonType") ); + if( aTmp >>= eButtonType ) + { + // Label + if(xInfo->hasPropertyByName( C2U("Label") )) + { + aTmp = xPropSet->getPropertyValue( C2U("Label") ); + OUString sTmp; + if( (aTmp >>= sTmp) && sTmp.getLength()) + { + aHLinkItem.SetName(sTmp); + } + } + + // URL + if(xInfo->hasPropertyByName( C2U("TargetURL" ))) + { + aTmp = xPropSet->getPropertyValue( C2U("TargetURL") ); + OUString sTmp; + if( (aTmp >>= sTmp) && sTmp.getLength()) + { + aHLinkItem.SetURL(sTmp); + } + } + + // Target + if(xInfo->hasPropertyByName( C2U("TargetFrame") )) + { + aTmp = xPropSet->getPropertyValue( C2U("TargetFrame") ); + OUString sTmp; + if( (aTmp >>= sTmp) && sTmp.getLength()) + { + aHLinkItem.SetTargetFrame(sTmp); + } + } + aHLinkItem.SetInsertMode(HLINK_BUTTON); + } + } + } + } + sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | + ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); + + rSet.Put(aHLinkItem); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + + +SwDrawFormShell::SwDrawFormShell(SwView &_rView) : + SwDrawBaseShell(_rView) +{ + SetHelpId(SW_DRAWFORMSHELL); + GetShell().NoEdit(sal_True); + SetName(String::CreateFromAscii("DrawForm")); +} + +SwDrawFormShell::~SwDrawFormShell() +{ +} + + + diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx new file mode 100644 index 000000000000..2bd3a59d0810 --- /dev/null +++ b/sw/source/ui/shells/drwbassh.cxx @@ -0,0 +1,995 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <tools/shl.hxx> +#include <hintids.hxx> +#include <helpid.h> +#include <swtypes.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/request.hxx> +#include <sfx2/bindings.hxx> +#include <svl/aeitem.hxx> +#include <svx/svdview.hxx> +#include <vcl/msgbox.hxx> +#include <svl/srchitem.hxx> +#include <svl/whiter.hxx> +#include <svx/swframevalidation.hxx> +#include <svx/anchorid.hxx> +#include <svx/htmlmode.hxx> +#include <uitool.hxx> +#include <fmtornt.hxx> +#include <cmdid.h> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <wview.hxx> +#include <edtwin.hxx> +#include <viewopt.hxx> +#include <dcontact.hxx> +#include <frmfmt.hxx> +#include <wrap.hxx> +#include <drawbase.hxx> +#include <drwbassh.hxx> +#include <swdtflvr.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdpage.hxx> +#include <svx/svditer.hxx> + +#include <shells.hrc> +#define SwDrawBaseShell +#include <sfx2/msg.hxx> +#include <swslots.hxx> +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include "swabstdlg.hxx" +#include "dialog.hrc" +#include <swundo.hxx> +#include <com/sun/star/text/HoriOrientation.hpp> +#include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/text/RelOrientation.hpp> + +#include <IDocumentDrawModelAccess.hxx> + +using namespace ::com::sun::star; + +SFX_IMPL_INTERFACE(SwDrawBaseShell, SwBaseShell, SW_RES(0)) +{ +} + +TYPEINIT1(SwDrawBaseShell,SwBaseShell) + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +SwDrawBaseShell::SwDrawBaseShell(SwView &_rView): + SwBaseShell( _rView ) +{ + GetShell().NoEdit(TRUE); + + SwEditWin& rWin = GetView().GetEditWin(); + + rWin.SetBezierMode(SID_BEZIER_MOVE); + + if ( !_rView.GetDrawFuncPtr() ) + _rView.GetEditWin().StdDrawMode( OBJ_NONE, TRUE ); + + SwTransferable::CreateSelection( GetShell() ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +SwDrawBaseShell::~SwDrawBaseShell() +{ + GetView().ExitDraw(); + GetShell().Edit(); + SwTransferable::ClearSelection( GetShell() ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwDrawBaseShell::Execute(SfxRequest &rReq) +{ + SwWrtShell *pSh = &GetShell(); + SdrView* pSdrView = pSh->GetDrawView(); + const SfxItemSet *pArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + BOOL bChanged = pSdrView->GetModel()->IsChanged(); + pSdrView->GetModel()->SetChanged(FALSE); + const SfxPoolItem* pItem = 0; + if(pArgs) + pArgs->GetItemState(nSlotId, FALSE, &pItem); + + //Sonderfall Align per Menue + if(pItem && nSlotId == SID_OBJECT_ALIGN) + { + DBG_ASSERT(PTR_CAST(SfxEnumItem, pItem),"SfxEnumItem erwartet"); + nSlotId = nSlotId + ((const SfxEnumItem*)pItem)->GetValue(); + nSlotId++; + } + + BOOL bAlignPossible = pSh->IsAlignPossible(); + + BOOL bTopParam = TRUE, bBottomParam = TRUE; + BOOL bNotify = FALSE; + BOOL bDone = FALSE; + SfxBindings& rBind = GetView().GetViewFrame()->GetBindings(); + + switch (nSlotId) + { + case FN_DRAW_WRAP_DLG: + { + if(pSdrView->AreObjectsMarked()) + { + if(!pArgs) + { + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if( rMarkList.GetMark(0) != 0 ) + { + SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND, + RES_ANCHOR, RES_ANCHOR, + RES_LR_SPACE, RES_UL_SPACE, + SID_HTML_MODE, SID_HTML_MODE, + FN_DRAW_WRAP_DLG, FN_DRAW_WRAP_DLG, + 0); + + aSet.Put(SfxBoolItem(SID_HTML_MODE, + 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()))); + + aSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, pSh->GetLayerId())); + + pSh->GetObjAttr(aSet); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, TRUE, RC_DLG_SWWRAPDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + + if (pDlg->Execute() == RET_OK) + { + const SfxPoolItem* pWrapItem; + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + if(SFX_ITEM_SET == pOutSet->GetItemState(FN_DRAW_WRAP_DLG, FALSE, &pWrapItem)) + { + short nLayer = ((const SfxInt16Item*)pWrapItem)->GetValue(); + if (nLayer == 1) + pSh->SelectionToHeaven(); + else + pSh->SelectionToHell(); + } + + pSh->SetObjAttr(*pOutSet); + } + delete pDlg; + } + } + } + } + break; + + case SID_ATTR_TRANSFORM: + { + if(pSdrView->AreObjectsMarked()) + { + if(!pArgs) + { + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if( rMarkList.GetMark(0) != 0 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SfxAbstractTabDialog *pDlg=NULL; + BOOL bCaption = FALSE; + + // Erlaubte Verankerungen: + short nAnchor = pSh->GetAnchorId(); + USHORT nAllowedAnchors = SVX_OBJ_AT_CNTNT|SVX_OBJ_IN_CNTNT; + USHORT nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell()); + + if( !((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))) ) + nAllowedAnchors |= SVX_OBJ_PAGE; + if ( pSh->IsFlyInFly() ) + nAllowedAnchors |= SVX_OBJ_AT_FLY; + + if (pObj->GetObjIdentifier() == OBJ_CAPTION ) + bCaption = TRUE; + + if (bCaption) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + AbstractSvxCaptionDialog* pCaptionDlg = + pFact->CreateCaptionDialog( NULL, pSdrView, nAllowedAnchors ); + pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) ); + pDlg = pCaptionDlg; + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + } + } + else + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + + AbstractSvxTransformTabDialog* pTransform = + pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, nAllowedAnchors ); + pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) ); + pDlg = pTransform; + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + } + } + SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked()); + + const USHORT* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() ); + SfxItemSet aSet( *aNewAttr.GetPool(), pRange ); + FieldUnit eMetric = ::GetDfltMetric(0 != dynamic_cast<SwWebView*>(&GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) ); + + aSet.Put( aNewAttr, FALSE ); + + if (bCaption) + pSdrView->GetAttributes( aSet ); + + aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor)); + BOOL bRTL; + aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, pSh->IsFrmVertical(TRUE, bRTL))); + aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT, bRTL)); + + SwFrmFmt* pFrmFmt = FindFrmFmt( pObj ); + + aSet.Put( pFrmFmt->GetFmtAttr(RES_FOLLOW_TEXT_FLOW) ); + + SwFmtVertOrient aVOrient((const SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT)); + aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, aVOrient.GetVertOrient())); + aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, aVOrient.GetRelationOrient() )); + aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, aVOrient.GetPos())); + + SwFmtHoriOrient aHOrient((const SwFmtHoriOrient&)pFrmFmt->GetFmtAttr(RES_HORI_ORIENT)); + aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, aHOrient.GetHoriOrient())); + aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, aHOrient.GetRelationOrient() )); + aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, aHOrient.IsPosToggle())); + aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos())); + + aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode)); + + pDlg->SetInputSet( &aSet ); + + if (pDlg->Execute() == RET_OK) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + pSh->StartAllAction(); + + // --> OD 2004-07-14 #i30451# + pSh->StartUndo(); + + pSdrView->SetGeoAttrToMarked(*pOutSet); + + if (bCaption) + pSdrView->SetAttributes(*pOutSet); + + BOOL bPosCorr = + SFX_ITEM_SET != pOutSet->GetItemState( + SID_ATTR_TRANSFORM_POS_X, FALSE ) && + SFX_ITEM_SET != pOutSet->GetItemState( + SID_ATTR_TRANSFORM_POS_Y, FALSE ); + + SfxItemSet aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1); + + bool bSingleSelection = rMarkList.GetMarkCount() == 1; + + const SfxPoolItem* pAnchorItem; + if(SFX_ITEM_SET == pOutSet->GetItemState( + SID_ATTR_TRANSFORM_ANCHOR, FALSE, &pAnchorItem)) + { + if(!bSingleSelection) + pSh->ChgAnchor(((const SfxInt16Item*)pAnchorItem) + ->GetValue(), FALSE, bPosCorr ); + else + { + SwFmtAnchor aAnchor(pFrmFmt->GetAnchor()); + aAnchor.SetType((RndStdIds)((const SfxInt16Item*)pAnchorItem)->GetValue()); + aFrmAttrSet.Put( aAnchor ); + } + } + const SfxPoolItem* pHoriOrient = 0; + const SfxPoolItem* pHoriRelation = 0; + const SfxPoolItem* pHoriPosition = 0; + const SfxPoolItem* pHoriMirror = 0; + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, FALSE, &pHoriOrient); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, FALSE, &pHoriRelation); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, FALSE, &pHoriPosition); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, FALSE, &pHoriMirror); + if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror) + { + if(pHoriOrient) + aHOrient.SetHoriOrient( + static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue()); + if(pHoriRelation) + aHOrient.SetRelationOrient( + static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue()); + if(pHoriPosition) + aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue()); + if(pHoriMirror) + aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue()); + aFrmAttrSet.Put(aHOrient); + } + + const SfxPoolItem* pVertOrient = 0; + const SfxPoolItem* pVertRelation = 0; + const SfxPoolItem* pVertPosition = 0; + pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, FALSE, &pVertOrient); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, FALSE, &pVertRelation); + pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, FALSE, &pVertPosition); + if(pVertOrient || pVertRelation || pVertPosition ) + { + if(pVertOrient) + aVOrient.SetVertOrient( + static_cast<const SfxInt16Item*>(pVertOrient)->GetValue()); + if(pVertRelation) + aVOrient.SetRelationOrient( + static_cast<const SfxInt16Item*>(pVertRelation)->GetValue()); + if(pVertPosition) + aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue()); + aFrmAttrSet.Put( aVOrient ); + } + const SfxPoolItem* pFollowItem = 0; + pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, FALSE, &pFollowItem); + if(pFollowItem) + aFrmAttrSet.Put(*pFollowItem); + + if(aFrmAttrSet.Count()) + pSh->SetDrawingAttr(aFrmAttrSet); + + rBind.InvalidateAll(FALSE); + + // --> OD 2004-07-14 #i30451# + pSh->EndUndo( UNDO_INSFMTATTR ); + + pSh->EndAllAction(); + } + delete pDlg; + + } + } + } + } + break; + + case SID_DELETE: + case FN_BACKSPACE: + if (pSh->IsObjSelected() && !pSdrView->IsTextEdit()) + { + bDone = TRUE; + + if( GetView().IsDrawRotate() ) + { + pSh->SetDragMode( SDRDRAG_MOVE ); + GetView().FlipDrawRotate(); + } + + pSh->SetModified(); + pSh->DelSelectedObj(); + + if (rReq.IsAPI() || + GetView().GetEditWin().IsObjectSelect() ) + { + // Wenn Basic-Aufruf, dann zurueck in die Textshell, da das + // Basic sonst keine Rueckkehrmoeglichkeit hat. + if (GetView().GetDrawFuncPtr()) + { + GetView().GetDrawFuncPtr()->Deactivate(); + GetView().SetDrawFuncPtr(NULL); + } + GetView().LeaveDrawCreate(); // In Selektionsmode wechseln + } + + if (pSh->IsSelFrmMode()) + { + pSh->LeaveSelFrmMode(); + // #105852# FME +// pSh->NoEdit(); + } + bNotify = TRUE; + } + break; + + case SID_GROUP: + if (pSh->IsObjSelected() > 1 && pSh->IsGroupAllowed()) + { + pSh->GroupSelection(); // Objekt gruppieren + rBind.Invalidate(SID_UNGROUP); + } + break; + + case SID_UNGROUP: + if (pSh->IsGroupSelected()) + { + pSh->UnGroupSelection(); // Objektgruppierung aufheben + rBind.Invalidate(SID_GROUP); + } + break; + + case SID_ENTER_GROUP: + if (pSh->IsGroupSelected()) + { + pSdrView->EnterMarkedGroup(); + rBind.InvalidateAll(FALSE); + } + break; + + case SID_LEAVE_GROUP: + if (pSdrView->IsGroupEntered()) + { + pSdrView->LeaveOneGroup(); + rBind.Invalidate(SID_ENTER_GROUP); + rBind.Invalidate(SID_UNGROUP); + } + break; + + case SID_OBJECT_ALIGN_LEFT: + case SID_OBJECT_ALIGN_CENTER: + case SID_OBJECT_ALIGN_RIGHT: + case SID_OBJECT_ALIGN_UP: + case SID_OBJECT_ALIGN_MIDDLE: + case SID_OBJECT_ALIGN_DOWN: + { + if ( bAlignPossible ) + { + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 && bAlignPossible ) + { // Objekte nicht aneinander ausrichten + + USHORT nAnchor = pSh->GetAnchorId(); + if (nAnchor == FLY_AS_CHAR) + { + sal_Int16 nVertOrient = -1; + + switch (nSlotId) + { + case SID_OBJECT_ALIGN_UP: + nVertOrient = text::VertOrientation::TOP; + break; + case SID_OBJECT_ALIGN_MIDDLE: + nVertOrient = text::VertOrientation::CENTER; + break; + case SID_OBJECT_ALIGN_DOWN: + nVertOrient = text::VertOrientation::BOTTOM; + break; + default: + break; + } + if (nVertOrient != -1) + { + pSh->StartAction(); + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SwFrmFmt* pFrmFmt = FindFrmFmt( pObj ); + SwFmtVertOrient aVOrient((SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT)); + aVOrient.SetVertOrient( nVertOrient ); + pFrmFmt->SetFmtAttr(aVOrient); + pSh->EndAction(); + } + break; + } + if (nAnchor == FLY_AT_PARA) + break; // Absatzverankerte Rahmen nicht ausrichten + } + + pSh->StartAction(); + switch (nSlotId) + { + case SID_OBJECT_ALIGN_LEFT: + pSdrView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE); + break; + case SID_OBJECT_ALIGN_CENTER: + pSdrView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE); + break; + case SID_OBJECT_ALIGN_RIGHT: + pSdrView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE); + break; + case SID_OBJECT_ALIGN_UP: + pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP); + break; + case SID_OBJECT_ALIGN_MIDDLE: + pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER); + break; + case SID_OBJECT_ALIGN_DOWN: + pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM); + break; + } + pSh->EndAction(); + } + } + break; + + case FN_FRAME_UP: + bTopParam = FALSE; + /* no break */ + case SID_FRAME_TO_TOP: + pSh->SelectionToTop( bTopParam ); + break; + + case FN_FRAME_DOWN: + bBottomParam = FALSE; + /* no break */ + case SID_FRAME_TO_BOTTOM: + pSh->SelectionToBottom( bBottomParam ); + break; + + case FN_NAME_SHAPE: + { + bDone = TRUE; + + if(1L == pSdrView->GetMarkedObjectCount()) + { + // #i68101# + SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L); + OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)"); + String aName(pSelected->GetName()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + + pDlg->SetCheckNameHdl(LINK(this, SwDrawBaseShell, CheckGroupShapeNameHdl)); + + if(RET_OK == pDlg->Execute()) + { + pDlg->GetName(aName); + pSelected->SetName(aName); + pSh->SetModified(); + } + + delete pDlg; + } + + break; + } + + // #i68101# + case FN_TITLE_DESCRIPTION_SHAPE: + { + bDone = TRUE; + + if(1L == pSdrView->GetMarkedObjectCount()) + { + SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L); + OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)"); + String aTitle(pSelected->GetTitle()); + String aDescription(pSelected->GetDescription()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + + if(RET_OK == pDlg->Execute()) + { + pDlg->GetTitle(aTitle); + pDlg->GetDescription(aDescription); + + pSelected->SetTitle(aTitle); + pSelected->SetDescription(aDescription); + + pSh->SetModified(); + } + + delete pDlg; + } + + break; + } + + default: + DBG_ASSERT(!this, "falscher Dispatcher"); + return; + } + if(!bDone) + { + if(nSlotId >= SID_OBJECT_ALIGN_LEFT && nSlotId <= SID_OBJECT_ALIGN_DOWN) + rBind.Invalidate(SID_ATTR_LONG_LRSPACE); + if (pSdrView->GetModel()->IsChanged()) + pSh->SetModified(); + else if (bChanged) + pSdrView->GetModel()->SetChanged(TRUE); + // 40220: Nach dem Loeschen von DrawObjekten ueber die API GPF durch Selbstzerstoerung + if(bNotify) + GetView().AttrChangedNotify(pSh); // ggf Shellwechsel... + } +} +/* -----------------------------27.02.2002 15:27------------------------------ + Checks whether a given name is allowed for a group shape + ---------------------------------------------------------------------------*/ +IMPL_LINK( SwDrawBaseShell, CheckGroupShapeNameHdl, AbstractSvxNameDialog*, pNameDialog ) +{ + SwWrtShell &rSh = GetShell(); + SdrView *pSdrView = rSh.GetDrawView(); + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + DBG_ASSERT(rMarkList.GetMarkCount() == 1, "wrong draw selection"); + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + const String sCurrentName = pObj->GetName(); + String sNewName; + pNameDialog->GetName(sNewName); + long nRet = 0; + if(!sNewName.Len() || sCurrentName == sNewName) + nRet = 1; + else + { + nRet = 1; + SdrModel* pModel = rSh.getIDocumentDrawModelAccess()->GetDrawModel(); + // --> OD 2006-03-09 #i51726# - all drawing objects can be named now. + // consider also drawing objects inside group objects +// SdrPage* pPage = pModel->GetPage(0); +// sal_uInt32 nCount = pPage->GetObjCount(); +// for( sal_uInt32 i=0; i< nCount; i++ ) +// { +// SdrObject* pTemp = pPage->GetObj(i); +// if(pObj != pTemp && pTemp->ISA(SdrObjGroup) && pTemp->GetName() == sNewName) +// { +// nRet = 0; +// break; +// } +// } + SdrObjListIter aIter( *(pModel->GetPage(0)), IM_DEEPWITHGROUPS ); + while( aIter.IsMore() ) + { + SdrObject* pTempObj = aIter.Next(); + if ( pObj != pTempObj && pTempObj->GetName() == sNewName ) + { + nRet = 0; + break; + } + } + // <-- + } + return nRet; +} +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void SwDrawBaseShell::GetState(SfxItemSet& rSet) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + BOOL bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT); + + if (!bProtected) // Im Parent nachsehen + bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + + while( nWhich ) + { + switch( nWhich ) + { + case FN_DRAW_WRAP_DLG: + case SID_ATTR_TRANSFORM: + case SID_FRAME_TO_TOP: + case SID_FRAME_TO_BOTTOM: + case FN_FRAME_UP: + case FN_FRAME_DOWN: + case SID_DELETE: + case FN_BACKSPACE: + if( bProtected || !rSh.IsObjSelected() ) + rSet.DisableItem( nWhich ); + break; + case SID_GROUP: + if ( rSh.IsObjSelected() < 2 || bProtected || !rSh.IsGroupAllowed() ) + rSet.DisableItem( nWhich ); + break; + case SID_UNGROUP: + if ( !rSh.IsGroupSelected() || bProtected ) + rSet.DisableItem( nWhich ); + break; + case SID_ENTER_GROUP: + if ( !rSh.IsGroupSelected() ) + rSet.DisableItem( nWhich ); + break; + case SID_LEAVE_GROUP: + if ( !pSdrView->IsGroupEntered() ) + rSet.DisableItem( nWhich ); + break; + case SID_OBJECT_ALIGN_LEFT: + case SID_OBJECT_ALIGN_CENTER: + case SID_OBJECT_ALIGN_RIGHT: + case SID_OBJECT_ALIGN_UP: + case SID_OBJECT_ALIGN_MIDDLE: + case SID_OBJECT_ALIGN_DOWN: + case SID_OBJECT_ALIGN: + if ( !rSh.IsAlignPossible() || bProtected ) + rSet.DisableItem( nWhich ); + else + { + SfxAllEnumItem aEnumItem(nWhich, USHRT_MAX); + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + //if only one object is selected it can only be vertically + // aligned because it is character bound + if( rMarkList.GetMarkCount() == 1 ) + { + aEnumItem.DisableValue(SID_OBJECT_ALIGN_LEFT); + aEnumItem.DisableValue(SID_OBJECT_ALIGN_CENTER); + aEnumItem.DisableValue(SID_OBJECT_ALIGN_RIGHT); + } + rSet.Put(aEnumItem); + } + break; + + case FN_NAME_SHAPE : + { + if(1L != pSdrView->GetMarkedObjectCount()) + { + rSet.DisableItem( nWhich ); + } + } + break; + + // #i68101# + case FN_TITLE_DESCRIPTION_SHAPE: + { + const bool bIsWebView(NULL != dynamic_cast<SwWebView*>(&GetView())); + + if(!bIsWebView && 1L != pSdrView->GetMarkedObjectCount()) + { + rSet.DisableItem( nWhich ); + } + } + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +BOOL SwDrawBaseShell::Disable(SfxItemSet& rSet, USHORT nWhich) +{ + BOOL bDisable = GetShell().IsSelObjProtected(FLYPROTECT_CONTENT); + + if (bDisable) + { + if (nWhich) + rSet.DisableItem( nWhich ); + else + { + SfxWhichIter aIter( rSet ); + nWhich = aIter.FirstWhich(); + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } + } + } + + return bDisable; +} + +/*-- 09.03.2004 13:15:03--------------------------------------------------- + Validate of drawing positions + -----------------------------------------------------------------------*/ +IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation ) +{ + SwWrtShell *pSh = &GetShell(); + pValidation->nMinHeight = MINFLY; + pValidation->nMinWidth = MINFLY; + + SwRect aBoundRect; + + // OD 18.09.2003 #i18732# - adjustment for allowing vertical position + // aligned to page for fly frame anchored to paragraph or to character. + const RndStdIds eAnchorType = static_cast<RndStdIds >(pValidation->nAnchorType); + const SwPosition* pCntntPos = 0; + SdrView* pSdrView = pSh->GetDrawView(); + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SwFrmFmt* pFrmFmt = FindFrmFmt( pObj ); + pCntntPos = pFrmFmt->GetAnchor().GetCntntAnchor(); + } + + pSh->CalcBoundRect( aBoundRect, eAnchorType, + pValidation->nHRelOrient, + pValidation->nVRelOrient, + pCntntPos, + pValidation->bFollowTextFlow, + pValidation->bMirror, NULL, &pValidation->aPercentSize); + + BOOL bRTL; + BOOL bIsInVertical = pSh->IsFrmVertical(TRUE, bRTL); + if(bIsInVertical) + { + Point aPos(aBoundRect.Pos()); + long nTmp = aPos.X(); + aPos.X() = aPos.Y(); + aPos.Y() = nTmp; + Size aSize(aBoundRect.SSize()); + nTmp = aSize.Width(); + aSize.Width() = aSize.Height(); + aSize.Height() = nTmp; + aBoundRect.Chg( aPos, aSize ); + //exchange width/height to enable correct values + nTmp = pValidation->nWidth; + pValidation->nWidth = pValidation->nHeight; + pValidation->nHeight = nTmp; + } + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) + { + // MinimalPosition + pValidation->nMinHPos = aBoundRect.Left(); + pValidation->nMinVPos = aBoundRect.Top(); + SwTwips nH = pValidation->nHPos; + SwTwips nV = pValidation->nVPos; + + if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right()) + { + if (pValidation->nHoriOrient == text::HoriOrientation::NONE) + { + pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right()); + nH = pValidation->nHPos; + } + else + pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos; + } + + if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right()) + pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos; + + if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom()) + { + if (pValidation->nVertOrient == text::VertOrientation::NONE) + { + pValidation->nVPos -= ((pValidation->nVPos + pValidation->nHeight) - aBoundRect.Bottom()); + nV = pValidation->nVPos; + } + else + pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos; + } + + if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom()) + pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos; + + if ( pValidation->nVertOrient != text::VertOrientation::NONE ) + nV = aBoundRect.Top(); + + if ( pValidation->nHoriOrient != text::HoriOrientation::NONE ) + nH = aBoundRect.Left(); + + pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth; + pValidation->nMaxHeight = aBoundRect.Bottom() - nV; + + pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight; + pValidation->nMaxWidth = aBoundRect.Right() - nH; + } + else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR)) + { + if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right()) + { + if (pValidation->nHoriOrient == text::HoriOrientation::NONE) + { + pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right()); + } + else + pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos; + } + + // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow + // and alignment at page areas. + const bool bMaxVPosAtBottom = !pValidation->bFollowTextFlow || + pValidation->nVRelOrient == text::RelOrientation::PAGE_FRAME || + pValidation->nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA; + { + SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom + ? aBoundRect.Bottom() + : aBoundRect.Height() ) - + pValidation->nHeight; + if ( pValidation->nVPos > nTmpMaxVPos ) + { + if (pValidation->nVertOrient == text::VertOrientation::NONE) + { + pValidation->nVPos = nTmpMaxVPos; + } + else + { + pValidation->nHeight = ( bMaxVPosAtBottom + ? aBoundRect.Bottom() + : aBoundRect.Height() ) - pValidation->nVPos; + } + } + } + + pValidation->nMinHPos = aBoundRect.Left(); + pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth; + + pValidation->nMinVPos = aBoundRect.Top(); + // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position + if ( bMaxVPosAtBottom ) + { + pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight; + } + else + { + pValidation->nMaxVPos = aBoundRect.Height() - pValidation->nHeight; + } + + // Maximale Breite Hoehe + const SwTwips nH = ( pValidation->nHoriOrient != text::HoriOrientation::NONE ) + ? aBoundRect.Left() + : pValidation->nHPos; + const SwTwips nV = ( pValidation->nVertOrient != text::VertOrientation::NONE ) + ? aBoundRect.Top() + : pValidation->nVPos; + pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV; + pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH; + } + else if (eAnchorType == FLY_AS_CHAR) + { + pValidation->nMinHPos = 0; + pValidation->nMaxHPos = 0; + + pValidation->nMaxHeight = aBoundRect.Height(); + pValidation->nMaxWidth = aBoundRect.Width(); + + pValidation->nMaxVPos = aBoundRect.Height(); + pValidation->nMinVPos = -aBoundRect.Height() + pValidation->nHeight; + if (pValidation->nMaxVPos < pValidation->nMinVPos) + { + pValidation->nMinVPos = pValidation->nMaxVPos; + pValidation->nMaxVPos = -aBoundRect.Height(); + } + } + if(bIsInVertical) + { + //restore width/height exchange + long nTmp = pValidation->nWidth; + pValidation->nWidth = pValidation->nHeight; + pValidation->nHeight = nTmp; + } + + if (pValidation->nMaxWidth < pValidation->nWidth) + pValidation->nWidth = pValidation->nMaxWidth; + if (pValidation->nMaxHeight < pValidation->nHeight) + pValidation->nHeight = pValidation->nMaxHeight; + return 0; +} + + + + diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx new file mode 100644 index 000000000000..94d49720a50c --- /dev/null +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -0,0 +1,960 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> + +#include <tools/shl.hxx> +#include <svx/svdview.hxx> +#include <editeng/spltitem.hxx> +#include <editeng/orphitem.hxx> +#include <editeng/brkitem.hxx> +#include <editeng/widwitem.hxx> +#include <editeng/kernitem.hxx> +#include <editeng/escpitem.hxx> +#ifndef _SVX_PARAITEM_HXX //autogen +#include <editeng/lspcitem.hxx> +#endif +#include <editeng/adjitem.hxx> +#include <editeng/crsditem.hxx> +#include <editeng/shdditem.hxx> +#include <editeng/hyznitem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/wghtitem.hxx> +#ifndef _SVX_CNTRITEM_HXX //autogen +#include <editeng/cntritem.hxx> +#endif +#include <editeng/postitem.hxx> +#include <editeng/frmdiritem.hxx> +#include <svx/svdoutl.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/whiter.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> +#include <sfx2/bindings.hxx> +#include <vcl/msgbox.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <editeng/flditem.hxx> +#include <editeng/editstat.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/htmlmode.hxx> +#include <editeng/langitem.hxx> +#include <editeng/unolingu.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/writingmodeitem.hxx> +#include <doc.hxx> +#include <wview.hxx> +#include <viewopt.hxx> +#include <wrtsh.hxx> +#include <uitool.hxx> +#include <pardlg.hxx> +#include <swdtflvr.hxx> +#include <drwtxtsh.hxx> +#include <swmodule.hxx> +#include <initui.hxx> // fuer SpellPointer +#include <edtwin.hxx> +#include <swwait.hxx> +#include <docstat.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + +#include <cmdid.h> +#include <globals.hrc> +#include <shells.hrc> +#include "swabstdlg.hxx" +#include "chrdlg.hrc" +#include "misc.hrc" + +//modified on Jul. 30th +#include <svl/languageoptions.hxx> +#include <editeng/langitem.hxx> +#include <svtools/langtab.hxx> +#include <svl/slstitm.hxx> +#include <string.h> + +#include <editeng/eeitem.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editdata.hxx> +#include <editeng/outliner.hxx> +#include <vcl/window.hxx> +#include <editeng/editview.hxx> +#include <vcl/outdev.hxx> + +#include <langhelper.hxx> + +using namespace ::com::sun::star; + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwDrawTextShell::Execute( SfxRequest &rReq ) +{ + SwWrtShell &rSh = GetShell(); + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); + + sal_uInt16 nSlot = rReq.GetSlot(); + + sal_uInt16 nWhich = GetPool().GetWhich(nSlot); + const SfxItemSet *pNewAttrs = rReq.GetArgs(); + + bool bRestoreSelection = false; + ESelection aOldSelection; + + sal_uInt16 nEEWhich = 0; + switch (nSlot) + { + case SID_LANGUAGE_STATUS: + { + aOldSelection = pOLV->GetSelection(); + if (!pOLV->GetEditView().HasSelection()) + { + bRestoreSelection = true; + pOLV->GetEditView().SelectCurrentWord(); + } + + bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh); + break; + } + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_FONTHEIGHT: + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + { + SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool(); + if( !pPool2 ) + pPool2 = aEditAttr.GetPool(); + SvxScriptSetItem aSetItem( nSlot, *pPool2 ); + + // #i78017 establish the same behaviour as in Writer + USHORT nScriptTypes = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; + if (nSlot == SID_ATTR_CHAR_FONT) + nScriptTypes = pOLV->GetSelectedScriptType(); + + aSetItem.PutItemForScriptType( nScriptTypes, pNewAttrs->Get( nWhich ) ); + aNewAttr.Put( aSetItem.GetItemSet() ); + } + break; + + case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; + + case SID_ATTR_CHAR_UNDERLINE: + { + FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); + aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE)); + } + break; + + case SID_ATTR_CHAR_OVERLINE: + { + FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle(); + aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE)); + } + break; + + case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; + case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break; + case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break; + case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break; + case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break; + case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; + case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break; + case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break; + case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break; + case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break; + case SID_ATTR_PARA_ADJUST_LEFT: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST)); + break; + case SID_ATTR_PARA_ADJUST_CENTER: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST)); + break; + case SID_ATTR_PARA_ADJUST_RIGHT: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST)); + break; + case SID_ATTR_PARA_ADJUST_BLOCK: + aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST)); + break; + + case SID_ATTR_PARA_LINESPACE_10: + { + SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL); + aItem.SetPropLineSpace(100); + aNewAttr.Put(aItem); + } + break; + case SID_ATTR_PARA_LINESPACE_15: + { + SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL); + aItem.SetPropLineSpace(150); + aNewAttr.Put(aItem); + } + break; + case SID_ATTR_PARA_LINESPACE_20: + { + SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL); + aItem.SetPropLineSpace(200); + aNewAttr.Put(aItem); + } + break; + + case FN_SET_SUPER_SCRIPT: + { + SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); + SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) + aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + + if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) + aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); + else + aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); + aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); + } + break; + case FN_SET_SUB_SCRIPT: + { + SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); + SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) + aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + + if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) + aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); + else + aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); + aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); + } + break; + + case SID_CHAR_DLG: + case SID_CHAR_DLG_FOR_PARAGRAPH: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + + if( !pArgs ) + { + aOldSelection = pOLV->GetSelection(); + if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH) + { + // select current paragraph (and restore selection later on...) + EditView & rEditView = pOLV->GetEditView(); + SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() ); + bRestoreSelection = true; + } + + SwView* pView = &GetView(); + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) ); + SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END); + + // util::Language gibts an der EditEngine nicht! Daher nicht im Set. + + aDlgAttr.Put( aEditAttr ); + aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) ); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR,0, sal_True ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + USHORT nRet = pDlg->Execute(); + if(RET_OK == nRet ) + { + rReq.Done( *( pDlg->GetOutputItemSet() ) ); + aNewAttr.Put(*pDlg->GetOutputItemSet()); + } + delete( pDlg ); + if(RET_OK != nRet) + return ; + } + else + aNewAttr.Put(*pArgs); + } + break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; + case SID_PARA_DLG: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + + if (!pArgs) + { + SwView* pView = &GetView(); + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) ); + SfxItemSet aDlgAttr(GetPool(), + EE_ITEMS_START, EE_ITEMS_END, + SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE, + SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT, + SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS, + SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS, + 0); + + aDlgAttr.Put(aEditAttr); + + // Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen. + // Muss natuerlich noch geaendert werden + // aDlgAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) ); + + aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) ); + aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) ); + aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) ); + aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) ); + aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) ); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + USHORT nRet = pDlg->Execute(); + if(RET_OK == nRet) + { + rReq.Done( *( pDlg->GetOutputItemSet() ) ); + aNewAttr.Put(*pDlg->GetOutputItemSet()); + } + delete( pDlg ); + if(RET_OK != nRet) + return; + } + else + aNewAttr.Put(*pArgs); + } + break; + case SID_AUTOSPELL_CHECK: + { +//!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView(); +//!! JP 16.03.2001: why?? pOutliner = pSdrView->GetTextEditOutliner(); + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + sal_uInt32 nCtrl = pOutliner->GetControlWord(); + + sal_Bool bSet = ((const SfxBoolItem&)rReq.GetArgs()->Get( + nSlot)).GetValue(); + if(bSet) + nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; + else + nCtrl &= ~EE_CNTRL_ONLINESPELLING; + pOutliner->SetControlWord(nCtrl); + + rView.ExecuteSlot(rReq); + } + break; + case SID_HYPERLINK_SETLINK: + { + const SfxPoolItem* pItem = 0; + if(pNewAttrs) + pNewAttrs->GetItemState(nSlot, sal_False, &pItem); + + if(pItem) + { + const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; + SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT); + aFld.SetTargetFrame(rHLinkItem.GetTargetFrame()); + + const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); + + if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField)) + { + // Feld selektieren, so dass es beim Insert geloescht wird + ESelection aSel = pOLV->GetSelection(); + aSel.nEndPos++; + pOLV->SetSelection(aSel); + } + pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD)); + } + } + break; + + case SID_TEXTDIRECTION_LEFT_TO_RIGHT: + case SID_TEXTDIRECTION_TOP_TO_BOTTOM: + // Shellwechsel! + { + SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); + SdrPageView* pTmpPV = pSdrView->GetSdrPageView(); + SdrView* pTmpView = pSdrView; + + pSdrView->SdrEndTextEdit(sal_True); + + SfxItemSet aAttr( *aNewAttr.GetPool(), + SDRATTR_TEXTDIRECTION, + SDRATTR_TEXTDIRECTION ); + + aAttr.Put( SvxWritingModeItem( + nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? + text::WritingMode_LR_TB + : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) ); + pTmpView->SetAttributes( aAttr ); + + rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False); + rSh.GetView().AttrChangedNotify( &rSh ); + } + return; + + case SID_ATTR_PARA_LEFT_TO_RIGHT: + case SID_ATTR_PARA_RIGHT_TO_LEFT: + { + SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); + SdrPageView* pTmpPV = pSdrView->GetSdrPageView(); + SdrView* pTmpView = pSdrView; + + pSdrView->SdrEndTextEdit(sal_True); + sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT; + + const SfxPoolItem* pPoolItem; + if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, TRUE, &pPoolItem ) ) + { + if( !( (SfxBoolItem*)pPoolItem)->GetValue() ) + bLeftToRight = !bLeftToRight; + } + SfxItemSet aAttr( *aNewAttr.GetPool(), + EE_PARA_JUST, EE_PARA_JUST, + EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, + 0 ); + + USHORT nAdjust = SVX_ADJUST_LEFT; + if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, TRUE, &pPoolItem ) ) + nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue(); + + if( bLeftToRight ) + { + aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); + if( nAdjust == SVX_ADJUST_RIGHT ) + aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); + } + else + { + aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) ); + if( nAdjust == SVX_ADJUST_LEFT ) + aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); + } + pTmpView->SetAttributes( aAttr ); + rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False ); + rSh.GetView().AttrChangedNotify( &rSh ); + } + return; + default: + ASSERT(!this, falscher Dispatcher); + return; + } + if(nEEWhich && pNewAttrs) + aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich); + + SetAttrToMarked(aNewAttr); + + GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); + + if (IsTextEdit() && pOLV->GetOutliner()->IsModified()) + rSh.SetModified(); + + if (bRestoreSelection) + { + // restore selection + pOLV->GetEditView().SetSelection( aOldSelection ); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwDrawTextShell::GetState(SfxItemSet& rSet) +{ + if (!IsTextEdit()) // Sonst manchmal Absturz! + return; + + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + + SfxItemSet aEditAttr( pOLV->GetAttribs() ); + const SfxPoolItem *pAdjust = 0, *pLSpace = 0, *pEscItem = 0; + int eAdjust, nLSpace, nEsc; + + while(nWhich) + { + USHORT nSlotId = GetPool().GetSlotId( nWhich ); + BOOL bFlag = FALSE; + switch( nSlotId ) + { + case SID_LANGUAGE_STATUS://20412: + { + nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);; + break; + } + case SID_ATTR_PARA_ADJUST_LEFT: eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST; + case SID_ATTR_PARA_ADJUST_RIGHT: eAdjust = SVX_ADJUST_RIGHT; goto ASK_ADJUST; + case SID_ATTR_PARA_ADJUST_CENTER: eAdjust = SVX_ADJUST_CENTER; goto ASK_ADJUST; + case SID_ATTR_PARA_ADJUST_BLOCK: eAdjust = SVX_ADJUST_BLOCK; goto ASK_ADJUST; +ASK_ADJUST: + { + if( !pAdjust ) + aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust); + + if( !pAdjust || IsInvalidItem( pAdjust )) + rSet.InvalidateItem( nSlotId ), nSlotId = 0; + else + bFlag = eAdjust == ((SvxAdjustItem*)pAdjust)->GetAdjust(); + } + break; + + case SID_ATTR_PARA_LINESPACE_10: nLSpace = 100; goto ASK_LINESPACE; + case SID_ATTR_PARA_LINESPACE_15: nLSpace = 150; goto ASK_LINESPACE; + case SID_ATTR_PARA_LINESPACE_20: nLSpace = 200; goto ASK_LINESPACE; +ASK_LINESPACE: + { + if( !pLSpace ) + aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace ); + + if( !pLSpace || IsInvalidItem( pLSpace )) + rSet.InvalidateItem( nSlotId ), nSlotId = 0; + else if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)-> + GetPropLineSpace() ) + bFlag = sal_True; + else + nSlotId = 0; + } + break; + + case FN_SET_SUPER_SCRIPT: nEsc = SVX_ESCAPEMENT_SUPERSCRIPT; + goto ASK_ESCAPE; + case FN_SET_SUB_SCRIPT: nEsc = SVX_ESCAPEMENT_SUBSCRIPT; + goto ASK_ESCAPE; +ASK_ESCAPE: + { + if( !pEscItem ) + pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT ); + + if( nEsc == ((const SvxEscapementItem*) + pEscItem)->GetEnumValue() ) + bFlag = sal_True; + else + nSlotId = 0; + } + break; + + case FN_THESAURUS_DLG: + { + // disable "Thesaurus" if the language is not supported + const SfxPoolItem &rItem = GetShell().GetDoc()->GetDefault( + GetWhichOfScript( RES_CHRATR_LANGUAGE, + GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage())) ); + LanguageType nLang = ((const SvxLanguageItem &) + rItem).GetLanguage(); + // + uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); + if (!xThes.is() || nLang == LANGUAGE_NONE || + !xThes->hasLocale( SvxCreateLocale( nLang ) )) + rSet.DisableItem( FN_THESAURUS_DLG ); + nSlotId = 0; + } + break; + case SID_HANGUL_HANJA_CONVERSION: + case SID_CHINESE_CONVERSION: + { + if (!SvtCJKOptions().IsAnyEnabled()) + { + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); + rSet.DisableItem(nWhich); + } + else + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); + } + break; + + case SID_TEXTDIRECTION_LEFT_TO_RIGHT: + case SID_TEXTDIRECTION_TOP_TO_BOTTOM: + if ( !SvtLanguageOptions().IsVerticalTextEnabled() ) + { + rSet.DisableItem( nSlotId ); + nSlotId = 0; + } + else + { + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + if( pOutliner ) + bFlag = pOutliner->IsVertical() == + (SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId); + else + { + text::WritingMode eMode = (text::WritingMode) + ( (const SvxWritingModeItem&) aEditAttr.Get( SDRATTR_TEXTDIRECTION ) ).GetValue(); + + if( nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT ) + { + bFlag = eMode == text::WritingMode_LR_TB; + } + else + { + bFlag = eMode != text::WritingMode_TB_RL; + } + } + } + break; + case SID_ATTR_PARA_LEFT_TO_RIGHT: + case SID_ATTR_PARA_RIGHT_TO_LEFT: + { + if ( !SvtLanguageOptions().IsCTLFontEnabled() ) + { + rSet.DisableItem( nWhich ); + nSlotId = 0; + } + else + { + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + if(pOutliner && pOutliner->IsVertical()) + { + rSet.DisableItem( nWhich ); + nSlotId = 0; + } + else + { + switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() ) + { + case FRMDIR_HORI_LEFT_TOP: + bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT; + break; + + case FRMDIR_HORI_RIGHT_TOP: + bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT; + break; + } + } + } + } + break; + case SID_TRANSLITERATE_HALFWIDTH: + case SID_TRANSLITERATE_FULLWIDTH: + case SID_TRANSLITERATE_HIRAGANA: + case SID_TRANSLITERATE_KATAGANA: + { + SvtCJKOptions aCJKOptions; + if(!aCJKOptions.IsChangeCaseMapEnabled()) + { + rSet.DisableItem(nWhich); + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); + } + else + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); + } + break; + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + SvtCTLOptions aCTLOptions; + sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); + if(!bEnabled) + rSet.DisableItem(nWhich); + } + break; + default: + nSlotId = 0; // don't know this slot + break; + } + + if( nSlotId ) + rSet.Put( SfxBoolItem( nWhich, bFlag )); + + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet) +{ + if (!IsTextEdit()) // Sonst Absturz! + return; + + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); + + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + USHORT nScriptType = pOLV->GetSelectedScriptType(); + while(nWhich) + { + sal_uInt16 nEEWhich = 0; + USHORT nSlotId = GetPool().GetSlotId( nWhich ); + switch( nSlotId ) + { + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_FONTHEIGHT: + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + { + SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool(); + if( !pEditPool ) + pEditPool = aEditAttr.GetPool(); + SvxScriptSetItem aSetItem( nSlotId, *pEditPool ); + aSetItem.GetItemSet().Put( aEditAttr, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); + if( pI ) + rSet.Put( *pI, nWhich ); + else + rSet.InvalidateItem( nWhich ); + } + break; + case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; + case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break; + case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break; + case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; + case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break; + case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break; + case SID_AUTOSPELL_CHECK: + { + const SfxPoolItem* pState = rView.GetSlotState(nWhich); + if (pState) + rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue())); + else + rSet.DisableItem( nWhich ); + break; + } + case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break; + case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break; + case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; + case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break; + case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH;break; + case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break; + case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break; + } + if(nEEWhich) + rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich); + + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq) +{ + if (!IsTextEdit()) // Sonst Absturz! + return; + + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + + ESelection aSel(pOLV->GetSelection()); + const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos); + sal_uInt16 nId = rReq.GetSlot(); + switch( nId ) + { + case SID_CUT: + if (bCopy) + pOLV->Cut(); + return; + + case SID_COPY: + if (bCopy) + pOLV->Copy(); + return; + + case SID_PASTE: + pOLV->PasteSpecial(); + break; + + default: + DBG_ERROR("falscher Dispatcher"); + return; + } +} + +/*-------------------------------------------------------------------- + Beschreibung: ClipBoard-Status + --------------------------------------------------------------------*/ +void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet) +{ + if (!IsTextEdit()) // Sonst Absturz! + return; + + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + ESelection aSel(pOLV->GetSelection()); + const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || + (aSel.nStartPos != aSel.nEndPos); + + + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while(nWhich) + { + switch(nWhich) + { + case SID_CUT: + case SID_COPY: + if( !bCopy ) + rSet.DisableItem( nWhich ); + break; + + case SID_PASTE: + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &GetView().GetEditWin() ) ); + + if( !aDataHelper.GetXTransferable().is() || + !SwTransferable::IsPaste( GetShell(), aDataHelper )) + rSet.DisableItem( SID_PASTE ); + } + break; + + case SID_PASTE_SPECIAL: + rSet.DisableItem( SID_PASTE_SPECIAL ); + break; + // --> OD 2008-06-20 #151110# + case SID_CLIPBOARD_FORMAT_ITEMS: + rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS ); + break; + // <-- + } + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Hyperlink-Status + --------------------------------------------------------------------*/ + +void SwDrawTextShell::StateInsert(SfxItemSet &rSet) +{ + if (!IsTextEdit()) // Sonst Absturz! + return; + + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while(nWhich) + { + switch(nWhich) + { + case SID_HYPERLINK_GETLINK: + { + SvxHyperlinkItem aHLinkItem; + aHLinkItem.SetInsertMode(HLINK_FIELD); + + const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); + + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + + if (pField->ISA(SvxURLField)) + { + aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation()); + aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL()); + aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame()); + } + } + else + { + String sSel(pOLV->GetSelected()); + sSel.Erase(255); + sSel.EraseTrailingChars(); + aHLinkItem.SetName(sSel); + } + + sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | + ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); + + rSet.Put(aHLinkItem); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx new file mode 100644 index 000000000000..4b8e2c65c5fc --- /dev/null +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -0,0 +1,902 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> +#include <i18npool/lang.h> +#include <svl/slstitm.hxx> +#include <svl/cjkoptions.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/langitem.hxx> +#include <svx/svdview.hxx> +#include <vcl/msgbox.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/objface.hxx> +#include <svx/svdotext.hxx> +#include <svx/xftsfit.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editview.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/scripttypeitem.hxx> +#include <sfx2/bindings.hxx> +#include <svx/fontwork.hxx> +#include <sfx2/request.hxx> +#include <svl/whiter.hxx> +#include <editeng/outliner.hxx> +#include <editeng/editstat.hxx> +#include <svx/svdoutl.hxx> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/i18n/TextConversionOption.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <swtypes.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <viewopt.hxx> +#include <initui.hxx> // fuer SpellPointer +#include <drwtxtsh.hxx> +#include <swundo.hxx> +#include <breakit.hxx> + +#include <cmdid.h> +#include <helpid.h> +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif + +#define SwDrawTextShell +#include <sfx2/msg.hxx> +#include <swslots.hxx> +#ifndef _POPUP_HRC +#include <popup.hrc> +#endif +#include <uitool.hxx> +#include <wview.hxx> +#include <swmodule.hxx> + +#include <svx/xtable.hxx> +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> + +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> + +#include <cppuhelper/bootstrap.hxx> + +#include "swabstdlg.hxx" //CHINA001 +#include "misc.hrc" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::i18n; + + + +SFX_IMPL_INTERFACE(SwDrawTextShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX)); + SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId()); +} + +TYPEINIT1(SwDrawTextShell,SfxShell) + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +void SwDrawTextShell::Init() +{ + SwWrtShell &rSh = GetShell(); + pSdrView = rSh.GetDrawView(); + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + //#97471# mouse click _and_ key input at the same time + if( !pOutliner ) + return ; + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + ULONG nCtrl = pOutliner->GetControlWord(); + nCtrl |= EE_CNTRL_AUTOCORRECT; + + SetUndoManager(&pOutliner->GetUndoManager()); + + // jetzt versuchen wir mal ein AutoSpell + + const SwViewOption* pVOpt = rSh.GetViewOptions(); + if(pVOpt->IsOnlineSpell()) + { + nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; + } + else + nCtrl &= ~(EE_CNTRL_ONLINESPELLING); + + pOutliner->SetControlWord(nCtrl); + pOLV->ShowCursor(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +SwDrawTextShell::SwDrawTextShell(SwView &rV) : + SfxShell(&rV), + rView(rV) +{ + SwWrtShell &rSh = GetShell(); + SetPool(rSh.GetAttrPool().GetSecondaryPool()); + + Init(); + + rSh.NoEdit(TRUE); + SetName(String::CreateFromAscii("ObjectText")); + SetHelpId(SW_DRWTXTSHELL); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +__EXPORT SwDrawTextShell::~SwDrawTextShell() +{ + if ( GetView().GetCurShell() == this ) + rView.ResetSubShell(); + + //MA 13. Nov. 96: Das kommt durchaus vor #33141#: + //(doppel-)Klick von einem Texteditmode in ein anderes Objekt, zwischendurch + //wird eine andere (Draw-)Shell gepusht, die alte aber noch nicht deletet. + //Dann wird vor dem Flush wieder ein DrawTextShell gepusht und der Mode ist + //eingeschaltet. In diesem Moment wird der Dispatcher geflusht und die alte + //DrawTextShell zerstoert. +// ASSERT( !pSdrView->IsTextEdit(), "TextEdit in DTor DrwTxtSh?" ); +// if (pSdrView->IsTextEdit()) +// GetShell().EndTextEdit(); // Danebengeklickt, Ende mit Edit + +// GetShell().Edit(); +} + +SwWrtShell& SwDrawTextShell::GetShell() +{ + return rView.GetWrtShell(); +} + + +/*-------------------------------------------------------------------- + Beschreibung: Slots mit dieser Statusmethode disablen + --------------------------------------------------------------------*/ + +void SwDrawTextShell::StateDisableItems( SfxItemSet &rSet ) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + + +/************************************************************************* +|* +|* Attribute setzen +|* +\************************************************************************/ + + + +void SwDrawTextShell::SetAttrToMarked(const SfxItemSet& rAttr) +{ + Rectangle aNullRect; + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + Rectangle aOutRect = pOLV->GetOutputArea(); + + if (aNullRect != aOutRect) + { + GetShell().GetDrawView()->SetAttributes(rAttr); +// Init(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +BOOL SwDrawTextShell::IsTextEdit() +{ + return pSdrView->IsTextEdit(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +void SwDrawTextShell::ExecFontWork(SfxRequest& rReq) +{ + SwWrtShell &rSh = GetShell(); + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) ); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if ( rReq.GetArgs() ) + { + pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), + ((const SfxBoolItem&) (rReq.GetArgs()-> + Get(SID_FONTWORK))).GetValue()); + } + else + pVFrame->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId()); + + pVFrame->GetBindings().Invalidate(SID_FONTWORK); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +void SwDrawTextShell::StateFontWork(SfxItemSet& rSet) +{ + const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + rSet.Put(SfxBoolItem(SID_FONTWORK, GetView().GetViewFrame()->HasChildWindow(nId))); +} + +/************************************************************************* +|* +|* SfxRequests fuer FontWork bearbeiten +|* +\************************************************************************/ + + + +void SwDrawTextShell::ExecFormText(SfxRequest& rReq) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pDrView = rSh.GetDrawView(); + + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + + if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) + { + const SfxItemSet& rSet = *rReq.GetArgs(); + const SfxPoolItem* pItem; + + //ask for the ViewFrame here - "this" may not be valid any longer! + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if ( pDrView->IsTextEdit() ) + { + //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and + // 'this' is not valid anymore + SwView& rTempView = GetView(); + pDrView->SdrEndTextEdit(sal_True); + //this removes the current shell from the dispatcher stack!! + rTempView.AttrChangedNotify(&rSh); + } + + if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem) == + SFX_ITEM_SET && + ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE ) + { + + const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)( + pVFrame->GetChildWindow(nId)->GetWindow()); + + pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(), + rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(), + ((const XFormTextStdFormItem*) pItem)-> + GetValue()); + } + else + pDrView->SetAttributes(rSet); + } + +} + +/************************************************************************* +|* +|* Statuswerte fuer FontWork zurueckgeben +|* +\************************************************************************/ + + + +void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pDrView = rSh.GetDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + const SdrObject* pObj = NULL; + SvxFontWorkDialog* pDlg = NULL; + + const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if ( pVFrame->HasChildWindow(nId) ) + pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow()); + + if ( rMarkList.GetMarkCount() == 1 ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + if ( pObj == NULL || !pObj->ISA(SdrTextObj) || + !((SdrTextObj*) pObj)->HasText() ) + { +#define XATTR_ANZ 12 + static const USHORT nXAttr[ XATTR_ANZ ] = + { XATTR_FORMTXTSTYLE, XATTR_FORMTXTADJUST, XATTR_FORMTXTDISTANCE, + XATTR_FORMTXTSTART, XATTR_FORMTXTMIRROR, XATTR_FORMTXTSTDFORM, + XATTR_FORMTXTHIDEFORM, XATTR_FORMTXTOUTLINE, XATTR_FORMTXTSHADOW, + XATTR_FORMTXTSHDWCOLOR, XATTR_FORMTXTSHDWXVAL, XATTR_FORMTXTSHDWYVAL + }; + for( USHORT i = 0; i < XATTR_ANZ; ) + rSet.DisableItem( nXAttr[ i++ ] ); + } + else + { + if ( pDlg ) + pDlg->SetColorTable(XColorTable::GetStdColorTable()); + + pDrView->GetAttributes( rSet ); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() ) + { + switch(rReq.GetSlot()) + { + case FN_THESAURUS_DLG: + pOLV->StartThesaurus(); + break; + + case SID_HANGUL_HANJA_CONVERSION: + pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, + i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False ); + break; + + case SID_CHINESE_CONVERSION: + { + //open ChineseTranslationDialog + Reference< XComponentContext > xContext( + ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one + if(xContext.is()) + { + Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); + if(xMCF.is()) + { + Reference< ui::dialogs::XExecutableDialog > xDialog( + xMCF->createInstanceWithContext( + rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog") + , xContext), UNO_QUERY); + Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); + if( xInit.is() ) + { + // initialize dialog + Reference< awt::XWindow > xDialogParentWindow(0); + Sequence<Any> aSeq(1); + Any* pArray = aSeq.getArray(); + PropertyValue aParam; + aParam.Name = rtl::OUString::createFromAscii("ParentWindow"); + aParam.Value <<= makeAny(xDialogParentWindow); + pArray[0] <<= makeAny(aParam); + xInit->initialize( aSeq ); + + //execute dialog + sal_Int16 nDialogRet = xDialog->execute(); + if( RET_OK == nDialogRet ) + { + //get some parameters from the dialog + sal_Bool bToSimplified = sal_True; + sal_Bool bUseVariants = sal_True; + sal_Bool bCommonTerms = sal_True; + Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); + if( xProp.is() ) + { + try + { + xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified; + xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants; + xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms; + } + catch( Exception& ) + { + } + } + + //execute translation + sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; + sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; + sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; + if( !bCommonTerms ) + nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; + + Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT, + nTargetLang, DEFAULTFONT_FLAGS_ONLYONE ); + + pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False ); + } + } + Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); + if( xComponent.is() ) + xComponent->dispose(); + } + } + } + break; + + default: + ASSERT(!this, "unexpected slot-id"); + } + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void SwDrawTextShell::ExecDraw(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + pSdrView = rSh.GetDrawView(); + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + + switch (rReq.GetSlot()) + { + case FN_INSERT_SOFT_HYPHEN: + case FN_INSERT_HARDHYPHEN: + case FN_INSERT_HARD_SPACE: + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + sal_Unicode cIns = 0; + switch(rReq.GetSlot()) + { + case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; + case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break; + case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break; + case SID_INSERT_RLM : cIns = CHAR_RLM ; break; + case SID_INSERT_LRM : cIns = CHAR_LRM ; break; + case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; + case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; + } + pOLV->InsertText( String(cIns)); + rReq.Done(); + } + break; + case SID_CHARMAP: + { // Sonderzeichen einfuegen + InsertSymbol(rReq); + break; + } + case FN_INSERT_STRING: + { + const SfxItemSet *pNewAttrs = rReq.GetArgs(); + sal_uInt16 nSlot = rReq.GetSlot(); + const SfxPoolItem* pItem = 0; + if(pNewAttrs) + { + pNewAttrs->GetItemState(nSlot, FALSE, &pItem ); + pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue()); + } + break; + } + + case SID_SELECTALL: + { + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + if(pOutliner) + { + ULONG nParaCount = pOutliner->GetParagraphCount(); + if (nParaCount > 0) + pOLV->SelectRange(0L, USHORT(nParaCount) ); + } + } + break; + + case FN_FORMAT_RESET: // delete hard text attributes + { + pOLV->RemoveAttribsKeepLanguages( true ); + pOLV->GetEditView().GetEditEngine()->RemoveFields(TRUE); + rReq.Done(); + } + break; + + case FN_ESCAPE: + if (pSdrView->IsTextEdit()) + { + // Shellwechsel! + rSh.EndTextEdit(); + SwView& rTempView = rSh.GetView(); + rTempView.ExitDraw(); + rSh.Edit(); + rTempView.AttrChangedNotify(&rSh); + return; + } + break; + case FN_DRAWTEXT_ATTR_DLG: + { + SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() ); + pSdrView->GetAttributes( aNewAttr ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( + &(GetView().GetViewFrame()->GetWindow()), + &aNewAttr, pSdrView ); + USHORT nResult = pDlg->Execute(); + + if (nResult == RET_OK) + { + if (pSdrView->AreObjectsMarked()) + { + pSdrView->SetAttributes(*pDlg->GetOutputItemSet()); + rReq.Done(*(pDlg->GetOutputItemSet())); + } + } + + delete( pDlg ); + } + } + break; + + default: + ASSERT(!this, "unexpected slot-id"); + return; + } + + GetView().GetViewFrame()->GetBindings().InvalidateAll(FALSE); + + if (IsTextEdit() && pOLV->GetOutliner()->IsModified()) + rSh.SetModified(); +} + +/*-------------------------------------------------------------------- + Beschreibung: Undo ausfuehren + --------------------------------------------------------------------*/ + + + +void SwDrawTextShell::ExecUndo(SfxRequest &rReq) +{ + if( IsTextEdit() ) + { + BOOL bCallBase = TRUE; + const SfxItemSet* pArgs = rReq.GetArgs(); + if( pArgs ) + { + USHORT nId = rReq.GetSlot(), nCnt = 1; + const SfxPoolItem* pItem; + switch( nId ) + { + case SID_UNDO: + case SID_REDO: + if( SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem ) && + 1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) ) + { + // then we make by ourself. + SfxUndoManager* pUndoManager = GetUndoManager(); + if( pUndoManager ) + { + if( SID_UNDO == nId ) + while( nCnt-- ) + pUndoManager->Undo(0); + else + while( nCnt-- ) + pUndoManager->Redo(0); + } + bCallBase = FALSE; + GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); + } + break; + } + } + if( bCallBase ) + { + SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame(); + pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface()); + } + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Zustand Undo + --------------------------------------------------------------------*/ + + + +void SwDrawTextShell::StateUndo(SfxItemSet &rSet) +{ + if ( !IsTextEdit() ) + return; + + SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame(); + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while( nWhich ) + { + switch ( nWhich ) + { + case SID_GETUNDOSTRINGS: + case SID_GETREDOSTRINGS: + { + SfxUndoManager* pUndoManager = GetUndoManager(); + if( pUndoManager ) + { + UniString (SfxUndoManager:: *fnGetComment)( USHORT ) const; + + sal_uInt16 nCount; + if( SID_GETUNDOSTRINGS == nWhich ) + { + nCount = pUndoManager->GetUndoActionCount(); + fnGetComment = &SfxUndoManager::GetUndoActionComment; + } + else + { + nCount = pUndoManager->GetRedoActionCount(); + fnGetComment = &SfxUndoManager::GetRedoActionComment; + } + if( nCount ) + { + String sList; + for( sal_uInt16 n = 0; n < nCount; ++n ) + ( sList += (pUndoManager->*fnGetComment)( n ) ) + += '\n'; + + SfxStringListItem aItem( nWhich ); + aItem.SetString( sList ); + rSet.Put( aItem ); + } + } + else + rSet.DisableItem( nWhich ); + } + break; + + default: + pSfxViewFrame->GetSlotState( nWhich, + pSfxViewFrame->GetInterface(), &rSet ); + } + + nWhich = aIter.NextWhich(); + } +} + +void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq ) +{ + using namespace i18n; + { + sal_uInt32 nMode = 0; + + switch( rReq.GetSlot() ) + { + case SID_TRANSLITERATE_UPPER: + nMode = TransliterationModules_LOWERCASE_UPPERCASE; + break; + case SID_TRANSLITERATE_LOWER: + nMode = TransliterationModules_UPPERCASE_LOWERCASE; + break; + + case SID_TRANSLITERATE_HALFWIDTH: + nMode = TransliterationModules_FULLWIDTH_HALFWIDTH; + break; + case SID_TRANSLITERATE_FULLWIDTH: + nMode = TransliterationModules_HALFWIDTH_FULLWIDTH; + break; + + case SID_TRANSLITERATE_HIRAGANA: + nMode = TransliterationModules_KATAKANA_HIRAGANA; + break; + case SID_TRANSLITERATE_KATAGANA: + nMode = TransliterationModules_HIRAGANA_KATAKANA; + break; + + default: + ASSERT(!this, "falscher Dispatcher"); + } + + if( nMode ) + { + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + pOLV->TransliterateText( nMode ); + } + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Sonderzeichen einfuegen (siehe SDraw: FUBULLET.CXX) + --------------------------------------------------------------------*/ + +void SwDrawTextShell::InsertSymbol(SfxRequest& rReq) +{ + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + if(!pOLV) + return; + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + if( pArgs ) + pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem); + + String sSym; + String sFontName; + if ( pItem ) + { + sSym = ((const SfxStringItem*)pItem)->GetValue(); + const SfxPoolItem* pFtItem = NULL; + pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem); + const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); + if ( pFontItem ) + sFontName = pFontItem->GetValue(); + } + + SfxItemSet aSet(pOLV->GetAttribs()); + USHORT nScript = pOLV->GetSelectedScriptType(); + SvxFontItem aSetDlgFont( RES_CHRATR_FONT ); + { + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); + aSetItem.GetItemSet().Put( aSet, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); + if( pI ) + aSetDlgFont = *(SvxFontItem*)pI; + else + aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( + SID_ATTR_CHAR_FONT, + GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) )); + if (!sFontName.Len()) + sFontName = aSetDlgFont.GetFamilyName(); + } + + Font aFont(sFontName, Size(1,1)); + if(!sSym.Len()) + { + SfxAllItemSet aAllSet( GetPool() ); + aAllSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) ); + + SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions()); + String sSymbolFont = aOpt.GetSymbolFont(); + if( sSymbolFont.Len() ) + aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); + else + aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) ); + + // Wenn Zeichen selektiert ist kann es angezeigt werden + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet, + rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); + USHORT nResult = pDlg->Execute(); + if( nResult == RET_OK ) + { + SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, FALSE ); + SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE ); + if ( pFontItem ) + { + aFont.SetName( pFontItem->GetFamilyName() ); + aFont.SetStyleName( pFontItem->GetStyleName() ); + aFont.SetCharSet( pFontItem->GetCharSet() ); + aFont.SetPitch( pFontItem->GetPitch() ); + } + + if ( pCItem ) + { + sSym = pCItem->GetValue(); + aOpt.SetSymbolFont(aFont.GetName()); + SW_MOD()->ApplyUsrPref(aOpt, &rView); + } + } + + delete( pDlg ); + } + + if( sSym.Len() ) + { + // nicht flackern + pOLV->HideCursor(); + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + pOutliner->SetUpdateMode(FALSE); + + SfxItemSet aOldSet( pOLV->GetAttribs() ); + SfxItemSet aFontSet( *aOldSet.GetPool(), + EE_CHAR_FONTINFO, EE_CHAR_FONTINFO, + EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK, + EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL, + 0 ); + aFontSet.Set( aOldSet ); + + // String einfuegen + pOLV->InsertText( sSym ); + + // attributieren (Font setzen) + SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() ); + SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(), + aFont.GetStyleName(), aFont.GetPitch(), + aFont.GetCharSet(), + EE_CHAR_FONTINFO ); + nScript = pBreakIt->GetAllScriptsOfText( sSym ); + if( SCRIPTTYPE_LATIN & nScript ) + aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO ); + if( SCRIPTTYPE_ASIAN & nScript ) + aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK ); + if( SCRIPTTYPE_COMPLEX & nScript ) + aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL ); + pOLV->SetAttribs(aFontAttribSet); + + // Selektion loeschen + ESelection aSel(pOLV->GetSelection()); + aSel.nStartPara = aSel.nEndPara; + aSel.nStartPos = aSel.nEndPos; + pOLV->SetSelection(aSel); + + // Alten Font restaurieren + pOLV->SetAttribs( aFontSet ); + + // ab jetzt wieder anzeigen + pOutliner->SetUpdateMode(TRUE); + pOLV->ShowCursor(); + + rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) ); + if(aFont.GetName().Len()) + rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) ); + rReq.Done(); + } +} +/*-- 22.10.2003 14:26:32--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SfxUndoManager* SwDrawTextShell::GetUndoManager() +{ + SwWrtShell &rSh = GetShell(); + pSdrView = rSh.GetDrawView(); + SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); + pOutliner = pSdrView->GetTextEditOutliner(); + return &pOutliner->GetUndoManager(); +} + + + diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx new file mode 100644 index 000000000000..5d972af52f72 --- /dev/null +++ b/sw/source/ui/shells/frmsh.cxx @@ -0,0 +1,1148 @@ + /************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> +#include <svl/whiter.hxx> +#include <svtools/imapobj.hxx> +#include <svl/srchitem.hxx> +#include <svtools/imap.hxx> +#include <sfx2/viewfrm.hxx> +#include <basic/sbstar.hxx> +#include <svl/rectitem.hxx> +#include <svl/ptitem.hxx> +#include <svl/stritem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/bolnitem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/protitem.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <sfx2/objface.hxx> +#include <svx/hlnkitem.hxx> +// --> OD 2009-07-07 #i73249# +#include <svx/svdview.hxx> +#include <vcl/msgbox.hxx> +// <-- + + +#include <fmturl.hxx> +#include <fmtclds.hxx> +#include <fmtcnct.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <wview.hxx> +#include <frmatr.hxx> +#include <uitool.hxx> +#include <frmfmt.hxx> +#include <frmsh.hxx> +#include <frmmgr.hxx> +#include <frmdlg.hxx> +#include <swevent.hxx> +#include <usrpref.hxx> +#include <edtwin.hxx> +#include <swdtflvr.hxx> +#include <swwait.hxx> +#include <docstat.hxx> +#include <IDocumentStatistics.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + +#include <helpid.h> +#include <cmdid.h> +#include <globals.hrc> +#include <popup.hrc> +#include <shells.hrc> +#include "swabstdlg.hxx" +#include "misc.hrc" +// --> OD 2009-07-14 #i73249# +#include <svx/dialogs.hrc> +// <-- + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +// Prototypen ------------------------------------------------------------ + +void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine); +const SwFrmFmt* lcl_GetFrmFmtByName(SwWrtShell& rSh, const String& rName) +{ + sal_uInt16 nCount = rSh.GetFlyCount(FLYCNTTYPE_FRM); + for( sal_uInt16 i = 0; i < nCount; i++) + { + const SwFrmFmt* pFmt = rSh.GetFlyNum(i, FLYCNTTYPE_FRM); + if(pFmt->GetName() == rName) + return pFmt; + } + return 0; +} + +#define SwFrameShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" + +SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_FRM_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_FRAME_TOOLBOX)); +} + + + +void SwFrameShell::Execute(SfxRequest &rReq) +{ + //Erstmal die, die keinen FrmMgr benoetigen. + SwWrtShell &rSh = GetShell(); + BOOL bMore = FALSE; + const SfxItemSet* pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + USHORT nSlot = rReq.GetSlot(); + + switch ( nSlot ) + { + case FN_FRAME_TO_ANCHOR: + if ( rSh.IsFrmSelected() ) + { + rSh.GotoFlyAnchor(); + rSh.EnterStdMode(); + rSh.CallChgLnk(); + } + break; + case SID_FRAME_TO_TOP: + rSh.SelectionToTop(); + break; + + case SID_FRAME_TO_BOTTOM: + rSh.SelectionToBottom(); + break; + + case FN_FRAME_UP: + rSh.SelectionToTop( FALSE ); + break; + + case FN_FRAME_DOWN: + rSh.SelectionToBottom( FALSE ); + break; + case FN_INSERT_FRAME: + if (!pArgs) + { + // Rahmen existiert bereits, Rahmendialog zur Bearbeitung oeffnen + SfxUInt16Item aDefPage(FN_FORMAT_FRAME_DLG, TP_COLUMN); + rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_FORMAT_FRAME_DLG, + SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, + &aDefPage, 0L ); + + } + else + { + // Rahmen existiert bereits, nur Spaltenanzahl wird geaendert + USHORT nCols = 1; + if(pArgs->GetItemState(SID_ATTR_COLUMNS, FALSE, &pItem) == SFX_ITEM_SET) + nCols = ((SfxUInt16Item *)pItem)->GetValue(); + + SfxItemSet aSet(GetPool(),RES_COL,RES_COL); + rSh.GetFlyFrmAttr( aSet ); + SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL)); + // GutterWidth wird nicht immer uebergeben, daher erst besorgen (siehe view2: Execute auf diesen Slot) + USHORT nGutterWidth = aCol.GetGutterWidth(); + if(!nCols ) + nCols++; + aCol.Init(nCols, nGutterWidth, aCol.GetWishWidth()); + aSet.Put(aCol); + // Vorlagen-AutoUpdate + SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); + if(pFmt && pFmt->IsAutoUpdateFmt()) + { + rSh.AutoUpdateFrame(pFmt, aSet); + } + else + { + rSh.StartAllAction(); + rSh.SetFlyFrmAttr( aSet ); + rSh.SetModified(); + rSh.EndAllAction(); + } + + } + return; + + case SID_HYPERLINK_SETLINK: + { + if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_HYPERLINK_SETLINK, FALSE, &pItem)) + { + const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; + const String& rURL = rHLinkItem.GetURL(); + const String& rTarget = rHLinkItem.GetTargetFrame(); + + SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); + rSh.GetFlyFrmAttr( aSet ); + SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) ); + + String sOldName(rHLinkItem.GetName()); + String sFlyName(rSh.GetFlyName()); + if (sOldName.ToUpperAscii() != sFlyName.ToUpperAscii()) + { + String sName(sOldName); + USHORT i = 1; + while (rSh.FindFlyByName(sName)) + { + sName = sOldName; + sName += '_'; + sName += String::CreateFromInt32(i++); + } + rSh.SetFlyName(sName); + } + aURL.SetURL( rURL, FALSE ); + aURL.SetTargetFrameName(rTarget); + + aSet.Put( aURL ); + rSh.SetFlyFrmAttr( aSet ); + } + } + break; + + case FN_FRAME_CHAIN: + rSh.GetView().GetEditWin().SetChainMode( !rSh.GetView().GetEditWin().IsChainMode() ); + break; + + case FN_FRAME_UNCHAIN: + rSh.Unchain( (SwFrmFmt&)*rSh.GetFlyFrmFmt() ); + GetView().GetViewFrame()->GetBindings().Invalidate(FN_FRAME_CHAIN); + break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + break; + } + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; + default: bMore = TRUE; + } + + if ( !bMore ) + { + return; + } + + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + BOOL bUpdateMgr = TRUE; + BOOL bCopyToFmt = FALSE; + switch ( nSlot ) + { + case SID_OBJECT_ALIGN_MIDDLE: + case FN_FRAME_ALIGN_VERT_CENTER: + aMgr.SetVertOrientation( text::VertOrientation::CENTER ); + break; + case SID_OBJECT_ALIGN_DOWN : + case FN_FRAME_ALIGN_VERT_BOTTOM: + aMgr.SetVertOrientation( text::VertOrientation::BOTTOM ); + break; + case SID_OBJECT_ALIGN_UP : + case FN_FRAME_ALIGN_VERT_TOP: + aMgr.SetVertOrientation( text::VertOrientation::TOP ); + break; + + case FN_FRAME_ALIGN_VERT_CHAR_CENTER: + aMgr.SetVertOrientation( text::VertOrientation::CHAR_CENTER ); + break; + + case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM: + aMgr.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM ); + break; + + case FN_FRAME_ALIGN_VERT_CHAR_TOP: + aMgr.SetVertOrientation( text::VertOrientation::CHAR_TOP ); + break; + + case FN_FRAME_ALIGN_VERT_ROW_CENTER: + aMgr.SetVertOrientation( text::VertOrientation::LINE_CENTER ); + break; + + case FN_FRAME_ALIGN_VERT_ROW_BOTTOM: + aMgr.SetVertOrientation( text::VertOrientation::LINE_BOTTOM ); + break; + + case FN_FRAME_ALIGN_VERT_ROW_TOP: + aMgr.SetVertOrientation( text::VertOrientation::LINE_TOP ); + break; + case SID_OBJECT_ALIGN_CENTER : + case FN_FRAME_ALIGN_HORZ_CENTER: + aMgr.SetHorzOrientation( text::HoriOrientation::CENTER ); + break; + case SID_OBJECT_ALIGN_RIGHT: + case FN_FRAME_ALIGN_HORZ_RIGHT: + aMgr.SetHorzOrientation( text::HoriOrientation::RIGHT ); + break; + case SID_OBJECT_ALIGN_LEFT: + case FN_FRAME_ALIGN_HORZ_LEFT: + aMgr.SetHorzOrientation( text::HoriOrientation::LEFT ); + break; + + case FN_SET_FRM_POSITION: + { + aMgr.SetAbsPos(((SfxPointItem &)pArgs->Get + (FN_SET_FRM_POSITION)).GetValue()); + } + break; + case SID_ATTR_BRUSH: + { + if(pArgs) + { + aMgr.SetAttrSet( *pArgs ); + bCopyToFmt = TRUE; + } + } + break; + case SID_ATTR_ULSPACE: + case SID_ATTR_LRSPACE: + { + if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem)) + { + aMgr.SetAttrSet( *pArgs ); + if(SID_ATTR_ULSPACE == nSlot && SID_ATTR_ULSPACE == nSlot) + bCopyToFmt = TRUE; + } + } + break; + case FN_FORMAT_FRAME_DLG: + { + const int nSel = rSh.GetSelectionType(); + if (nSel & nsSelectionType::SEL_GRF) + { + rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG); + bUpdateMgr = FALSE; + } + else + { + SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + FN_GET_PRINT_AREA, FN_GET_PRINT_AREA, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + SID_ATTR_BRUSH, SID_ATTR_BRUSH, + SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, + FN_SURROUND, FN_HORI_ORIENT, + FN_SET_FRM_NAME, FN_SET_FRM_NAME, + FN_KEEP_ASPECT_RATIO, FN_KEEP_ASPECT_RATIO, + SID_DOCFRAME, SID_DOCFRAME, + SID_HTML_MODE, SID_HTML_MODE, + FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME, + FN_PARAM_CHAIN_PREVIOUS, FN_PARAM_CHAIN_NEXT, + 0); + + const SwViewOption* pVOpt = rSh.GetViewOptions(); + if(nSel & nsSelectionType::SEL_OLE) + { + aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, + pVOpt->IsKeepRatio())); + } + aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell()))); + aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName())); + if( nSel & nsSelectionType::SEL_OLE ) + { + // --> OD 2009-07-13 #i73249# +// aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText())); + aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) ); + // <-- + } + + const SwRect &rPg = rSh.GetAnyCurRect(RECT_PAGE); + SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height()); + aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE)); + aSet.Put(aFrmSize); + + const SwRect &rPr = rSh.GetAnyCurRect(RECT_PAGE_PRT); + SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height()); + aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA)); + aSet.Put(aPrtSize); + + aSet.Put(aMgr.GetAttrSet()); + aSet.SetParent( aMgr.GetAttrSet().GetParent() ); + + // Bei %-Werten Groesse initialisieren + SwFmtFrmSize& rSize = (SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE); + if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) + rSize.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width()); + if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff) + rSize.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height()); + + UINT16 nDefPage = 0; + if(pArgs && pArgs->GetItemState(FN_FORMAT_FRAME_DLG, FALSE, &pItem) == SFX_ITEM_SET) + nDefPage = ((SfxUInt16Item *)pItem)->GetValue(); + + aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame())); + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric) )); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD, + GetView().GetViewFrame(), + GetView().GetWindow(), + aSet, FALSE, + nSel & nsSelectionType::SEL_GRF ? DLG_FRM_GRF : + nSel & nsSelectionType::SEL_OLE ? DLG_FRM_OLE : + DLG_FRM_STD, + FALSE, + nDefPage); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + + if ( pDlg->Execute() ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + if(pOutSet) + { + rReq.Done(*pOutSet); + if(nSel & nsSelectionType::SEL_OLE && + SFX_ITEM_SET == pOutSet->GetItemState(FN_KEEP_ASPECT_RATIO, TRUE, &pItem)) + { + SwViewOption aUsrPref( *pVOpt ); + aUsrPref.SetKeepRatio(((const SfxBoolItem*)pItem)->GetValue()); + SW_MOD()->ApplyUsrPref(aUsrPref, &GetView()); + } + if (SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_ALT_NAME, TRUE, &pItem)) + { + // --> OD 2009-07-13 #i73249# +// rSh.SetAlternateText(((const SfxStringItem*)pItem)->GetValue()); + rSh.SetObjTitle(((const SfxStringItem*)pItem)->GetValue()); + // <-- + } + // Vorlagen-AutoUpdate + SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); + if(pFmt && pFmt->IsAutoUpdateFmt()) + { + rSh.AutoUpdateFrame(pFmt, *pOutSet); + // alles, dass das Format nicht kann, muss hart + // gesetzt werden + if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, FALSE, &pItem)) + rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue()); + SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE, + RES_SURROUND, RES_SURROUND, + RES_ANCHOR, RES_ANCHOR, + RES_VERT_ORIENT,RES_HORI_ORIENT, + 0); + aShellSet.Put(*pOutSet); + aMgr.SetAttrSet(aShellSet); + if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, FALSE, &pItem)) + rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue()); + } + else + aMgr.SetAttrSet( *pOutSet ); + + const SwFrmFmt* pCurrFlyFmt = rSh.GetFlyFrmFmt(); + if(SFX_ITEM_SET == + pOutSet->GetItemState(FN_PARAM_CHAIN_PREVIOUS, + FALSE, &pItem)) + { + rSh.HideChainMarker(); + + String sPrevName = + ((const SfxStringItem*)pItem)->GetValue(); + const SwFmtChain &rChain = pCurrFlyFmt->GetChain(); + //needs cast - no non-const method available + SwFlyFrmFmt* pFlyFmt = + (SwFlyFrmFmt*)rChain.GetPrev(); + if(pFlyFmt) + { + if (pFlyFmt->GetName() != sPrevName) + { + rSh.Unchain(*pFlyFmt); + } + else + sPrevName.Erase(); + } + + if(sPrevName.Len()) + { + //needs cast - no non-const method available + SwFrmFmt* pPrevFmt = (SwFrmFmt*) + lcl_GetFrmFmtByName(rSh, sPrevName); + DBG_ASSERT(pPrevFmt, "No frame found!"); + if(pPrevFmt) + { + rSh.Chain(*pPrevFmt, *pCurrFlyFmt); + } + } + rSh.SetChainMarker(); + } + if(SFX_ITEM_SET == + pOutSet->GetItemState(FN_PARAM_CHAIN_NEXT, FALSE, + &pItem)) + { + rSh.HideChainMarker(); + String sNextName = + ((const SfxStringItem*)pItem)->GetValue(); + const SwFmtChain &rChain = pCurrFlyFmt->GetChain(); + //needs cast - no non-const method available + SwFlyFrmFmt* pFlyFmt = + (SwFlyFrmFmt*)rChain.GetNext(); + if(pFlyFmt) + { + if (pFlyFmt->GetName() != sNextName) + { + rSh.Unchain(*((SwFlyFrmFmt*) pCurrFlyFmt)); + } + else + sNextName.Erase(); + } + + if(sNextName.Len()) + { + //needs cast - no non-const method available + SwFrmFmt* pNextFmt = (SwFrmFmt*) + lcl_GetFrmFmtByName(rSh, sNextName); + DBG_ASSERT(pNextFmt, "No frame found!"); + if(pNextFmt) + { + rSh.Chain(*(SwFrmFmt*) + pCurrFlyFmt, *pNextFmt); + } + } + rSh.SetChainMarker(); + } + } + } + else + bUpdateMgr = FALSE; + delete pDlg; + } + } + break; + case FN_FRAME_MIRROR_ON_EVEN_PAGES: + { + SwFmtHoriOrient aHori(aMgr.GetHoriOrient()); + BOOL bMirror = !aHori.IsPosToggle(); + aHori.SetPosToggle(bMirror); + SfxItemSet aSet(GetPool(), RES_HORI_ORIENT, RES_HORI_ORIENT); + aSet.Put(aHori); + aMgr.SetAttrSet(aSet); + bCopyToFmt = TRUE; + rReq.SetReturnValue(SfxBoolItem(nSlot, bMirror)); + } + break; + // --> OD 2009-07-14 #i73249# + case FN_TITLE_DESCRIPTION_SHAPE: + { + bUpdateMgr = FALSE; + SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); + if ( pSdrView && + pSdrView->GetMarkedObjectCount() == 1 ) + { + String aDescription(rSh.GetObjDescription()); + String aTitle(rSh.GetObjTitle()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractSvxObjectTitleDescDialog* pDlg = + pFact->CreateSvxObjectTitleDescDialog( NULL, + aTitle, + aDescription ); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + + if ( pDlg->Execute() == RET_OK ) + { + pDlg->GetDescription(aDescription); + pDlg->GetTitle(aTitle); + + rSh.SetObjDescription(aDescription); + rSh.SetObjTitle(aTitle); + } + + delete pDlg; + } + } + break; + // <-- + default: + ASSERT( !this, "falscher Dispatcher" ); + return; + } + // Vorlagen-AutoUpdate + SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); + if ( bUpdateMgr ) + { + if(bCopyToFmt && pFmt && pFmt->IsAutoUpdateFmt()) + { + rSh.AutoUpdateFrame(pFmt, aMgr.GetAttrSet()); + } + else + aMgr.UpdateFlyFrm(); + } + +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwFrameShell::GetState(SfxItemSet& rSet) +{ + SwWrtShell &rSh = GetShell(); + BOOL bHtmlMode = 0 != ::GetHtmlMode(rSh.GetView().GetDocShell()); + if (rSh.IsFrmSelected()) + { + SfxItemSet aSet( rSh.GetAttrPool(), + RES_LR_SPACE, RES_UL_SPACE, + RES_PROTECT, RES_HORI_ORIENT, + RES_OPAQUE, RES_OPAQUE, + RES_PRINT, RES_OPAQUE, + 0 ); + rSh.GetFlyFrmAttr( aSet ); + + BOOL bProtect = rSh.IsSelObjProtected(FLYPROTECT_POS); + BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + + bProtect |= bParentCntProt; + + const USHORT eFrmType = rSh.GetFrmType(0,TRUE); + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE ); + + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) + { + case RES_FRM_SIZE: + { + SwFmtFrmSize aSz(aMgr.GetFrmSize()); + rSet.Put(aSz); + } + break; + case RES_VERT_ORIENT: + case RES_HORI_ORIENT: + case SID_ATTR_ULSPACE: + case SID_ATTR_LRSPACE: + case RES_LR_SPACE: + case RES_UL_SPACE: + case RES_PROTECT: + case RES_OPAQUE: + case RES_PRINT: + case RES_SURROUND: + { + rSet.Put(aSet.Get(GetPool().GetWhich(nWhich), TRUE )); + } + break; + case SID_OBJECT_ALIGN_LEFT : + case SID_OBJECT_ALIGN_CENTER : + case SID_OBJECT_ALIGN_RIGHT : + case FN_FRAME_ALIGN_HORZ_CENTER: + case FN_FRAME_ALIGN_HORZ_RIGHT: + case FN_FRAME_ALIGN_HORZ_LEFT: + if ( (eFrmType & FRMTYPE_FLY_INCNT) || + bProtect || + (nWhich == FN_FRAME_ALIGN_HORZ_CENTER || nWhich == SID_OBJECT_ALIGN_CENTER)&& bHtmlMode ) + rSet.DisableItem( nWhich ); + break; + case FN_FRAME_ALIGN_VERT_ROW_TOP: + case FN_FRAME_ALIGN_VERT_ROW_CENTER: + case FN_FRAME_ALIGN_VERT_ROW_BOTTOM: + case FN_FRAME_ALIGN_VERT_CHAR_TOP: + case FN_FRAME_ALIGN_VERT_CHAR_CENTER: + case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM: + if ( !(eFrmType & FRMTYPE_FLY_INCNT) || bProtect + || bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich ) + rSet.DisableItem( nWhich ); + break; + + case SID_OBJECT_ALIGN_UP : + case SID_OBJECT_ALIGN_MIDDLE : + case SID_OBJECT_ALIGN_DOWN : + + case FN_FRAME_ALIGN_VERT_TOP: + case FN_FRAME_ALIGN_VERT_CENTER: + case FN_FRAME_ALIGN_VERT_BOTTOM: + if ( bProtect || bHtmlMode && eFrmType & FRMTYPE_FLY_ATCNT) + rSet.DisableItem( nWhich ); + else + { + USHORT nId = 0; + if (eFrmType & FRMTYPE_FLY_INCNT) + { + switch (nWhich) + { + case SID_OBJECT_ALIGN_UP : + case FN_FRAME_ALIGN_VERT_TOP: + nId = STR_TOP_BASE; break; + case SID_OBJECT_ALIGN_MIDDLE : + case FN_FRAME_ALIGN_VERT_CENTER: + nId = STR_CENTER_BASE; break; + case SID_OBJECT_ALIGN_DOWN : + case FN_FRAME_ALIGN_VERT_BOTTOM: + if(!bHtmlMode) + nId = STR_BOTTOM_BASE; + else + rSet.DisableItem( nWhich ); + break; + } + } + else + { + if (nWhich != FN_FRAME_ALIGN_VERT_TOP && + nWhich != SID_OBJECT_ALIGN_UP ) + { + if (aMgr.GetAnchor() == FLY_AT_FLY) + { + const SwFrmFmt* pFmt = rSh.IsFlyInFly(); + if (pFmt) + { + const SwFmtFrmSize& rFrmSz = pFmt->GetFrmSize(); + if (rFrmSz.GetHeightSizeType() != ATT_FIX_SIZE) + { + rSet.DisableItem( nWhich ); + break; + } + } + } + } + switch (nWhich) + { + case SID_OBJECT_ALIGN_UP : + case FN_FRAME_ALIGN_VERT_TOP: + nId = STR_TOP; break; + case SID_OBJECT_ALIGN_MIDDLE: + case FN_FRAME_ALIGN_VERT_CENTER: + nId = STR_CENTER_VERT; break; + case SID_OBJECT_ALIGN_DOWN: + case FN_FRAME_ALIGN_VERT_BOTTOM: + nId = STR_BOTTOM; break; + } + } + if ( nId ) + rSet.Put( SfxStringItem( nWhich, SW_RES(nId) )); + } + break; + case SID_HYPERLINK_GETLINK: + { + String sURL; + SvxHyperlinkItem aHLinkItem; + const SfxPoolItem* pItem; + + SfxItemSet aURLSet(GetPool(), RES_URL, RES_URL); + rSh.GetFlyFrmAttr( aURLSet ); + + if(SFX_ITEM_SET == aURLSet.GetItemState(RES_URL, TRUE, &pItem)) + { + const SwFmtURL* pFmtURL = (const SwFmtURL*)pItem; + aHLinkItem.SetURL(pFmtURL->GetURL()); + aHLinkItem.SetTargetFrame(pFmtURL->GetTargetFrameName()); + aHLinkItem.SetName(rSh.GetFlyName()); + } + + aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | + (bHtmlMode ? HLINK_HTMLMODE : 0))); + + rSet.Put(aHLinkItem); + } + break; + + case FN_FRAME_CHAIN: + { + const int nSel = rSh.GetSelectionType(); + if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE) + rSet.DisableItem( FN_FRAME_CHAIN ); + else + { + const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt(); + if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || + !pFmt || pFmt->GetChain().GetNext() ) + { + rSet.DisableItem( FN_FRAME_CHAIN ); + } + else + { + BOOL bChainMode = rSh.GetView().GetEditWin().IsChainMode(); + rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) ); + } + } + } + break; + case FN_FRAME_UNCHAIN: + { + const int nSel = rSh.GetSelectionType(); + if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE) + rSet.DisableItem( FN_FRAME_UNCHAIN ); + else + { + const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt(); + if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || + !pFmt || !pFmt->GetChain().GetNext() ) + { + rSet.DisableItem( FN_FRAME_UNCHAIN ); + } + } + } + break; + case SID_FRAME_TO_TOP: + case SID_FRAME_TO_BOTTOM: + case FN_FRAME_UP: + case FN_FRAME_DOWN: + if ( bParentCntProt ) + rSet.DisableItem( nWhich ); + break; + case FN_FORMAT_FRAME_DLG: + { + const int nSel = rSh.GetSelectionType(); + if ( bParentCntProt || nSel & nsSelectionType::SEL_GRF) + rSet.DisableItem( nWhich ); + } + break; + // --> OD 2009-07-07 #i73249# + case FN_TITLE_DESCRIPTION_SHAPE: + { + SwWrtShell &rWrtSh = GetShell(); + SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList(); + if ( !pSdrView || + pSdrView->GetMarkedObjectCount() != 1 ) + { + rSet.DisableItem( nWhich ); + } + + } + break; + // <-- + default: + /* do nothing */; + break; + } + nWhich = aIter.NextWhich(); + } + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Ctor fuer FrameShell + --------------------------------------------------------------------*/ + + +SwFrameShell::SwFrameShell(SwView &_rView) : + SwBaseShell( _rView ) +{ + SetName(String::CreateFromAscii("Frame")); + SetHelpId(SW_FRAMESHELL); + + /* #96392# Use this to announce it is the frame shell who creates the + selection. */ + SwTransferable::CreateSelection( _rView.GetWrtShell(), (ViewShell *) this ); +} + +SwFrameShell::~SwFrameShell() +{ + /* #96392# Only clear the selection if it was this frame shell who created + it. */ + SwTransferable::ClearSelection( GetShell(), (ViewShell *) this ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +void SwFrameShell::ExecFrameStyle(SfxRequest& rReq) +{ + SwWrtShell &rSh = GetShell(); + BOOL bDefault = FALSE; + if (!rSh.IsFrmSelected()) + return; + + // Erst Default-BoxItem aus Pool holen. Wenn ungleich normalem Boxitem, + // dann ist es bereits geaendert worden (neues ist kein Default). + const SvxBoxItem* pPoolBoxItem = (const SvxBoxItem*)::GetDfltAttr(RES_BOX); + + const SfxItemSet *pArgs = rReq.GetArgs(); + SfxItemSet aFrameSet(rSh.GetAttrPool(), RES_BOX, RES_BOX); + + rSh.GetFlyFrmAttr( aFrameSet ); + const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aFrameSet.Get(RES_BOX); + + if (pPoolBoxItem == &rBoxItem) + bDefault = TRUE; + + SvxBoxItem aBoxItem(rBoxItem); + + SvxBorderLine aBorderLine; + const SfxPoolItem *pItem = 0; + + if(pArgs) //irgendein Controller kann auch mal nichts liefern #48169# + { + switch (rReq.GetSlot()) + { + case SID_ATTR_BORDER: + { + if (pArgs->GetItemState(RES_BOX, TRUE, &pItem) == SFX_ITEM_SET) + { + SvxBoxItem aNewBox(*((SvxBoxItem *)pItem)); + const SvxBorderLine* pBorderLine; + + if ((pBorderLine = aBoxItem.GetTop()) != NULL) + lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = aBoxItem.GetBottom()) != NULL) + lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = aBoxItem.GetLeft()) != NULL) + lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = aBoxItem.GetRight()) != NULL) + lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); + + if(aBorderLine.GetOutWidth() == 0) + { + aBorderLine.SetInWidth(0); + aBorderLine.SetOutWidth(DEF_LINE_WIDTH_0); + aBorderLine.SetDistance(0); + } + //Distance nur setzen, wenn der Request vom Controller kommt + + if(!StarBASIC::IsRunning()) + { + aNewBox.SetDistance( rBoxItem.GetDistance() ); + } + + aBoxItem = aNewBox; + SvxBorderLine aDestBorderLine; + + if ((pBorderLine = aBoxItem.GetTop()) != NULL) + aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); + if ((pBorderLine = aBoxItem.GetBottom()) != NULL) + aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); + if ((pBorderLine = aBoxItem.GetLeft()) != NULL) + aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); + if ((pBorderLine = aBoxItem.GetRight()) != NULL) + aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); + } + } + break; + + case SID_FRAME_LINESTYLE: + { + if (pArgs->GetItemState(SID_FRAME_LINESTYLE, FALSE, &pItem) == SFX_ITEM_SET) + { + const SvxLineItem* pLineItem = + (const SvxLineItem*)pItem; + + if ( pLineItem->GetLine() ) + { + aBorderLine = *(pLineItem->GetLine()); + + if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() && + !aBoxItem.GetLeft() && !aBoxItem.GetRight()) + { + aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); + } + else + { + if( aBoxItem.GetTop() ) + { + aBorderLine.SetColor( aBoxItem.GetTop()->GetColor() ); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); + } + if( aBoxItem.GetBottom() ) + { + aBorderLine.SetColor( aBoxItem.GetBottom()->GetColor()); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); + } + if( aBoxItem.GetLeft() ) + { + aBorderLine.SetColor( aBoxItem.GetLeft()->GetColor()); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); + } + if( aBoxItem.GetRight() ) + { + aBorderLine.SetColor(aBoxItem.GetRight()->GetColor()); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); + } + } + } + else + { + aBoxItem.SetLine(0, BOX_LINE_TOP); + aBoxItem.SetLine(0, BOX_LINE_BOTTOM); + aBoxItem.SetLine(0, BOX_LINE_LEFT); + aBoxItem.SetLine(0, BOX_LINE_RIGHT); + } + } + } + break; + + case SID_FRAME_LINECOLOR: + { + if (pArgs->GetItemState(SID_FRAME_LINECOLOR, FALSE, &pItem) == SFX_ITEM_SET) + { + const Color& rNewColor = ((const SvxColorItem*)pItem)->GetValue(); + + if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() && + !aBoxItem.GetLeft() && !aBoxItem.GetRight()) + { + aBorderLine.SetColor( rNewColor ); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); + aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); + } + else + { + if ( aBoxItem.GetTop() ) + ((SvxBorderLine*)aBoxItem.GetTop())->SetColor( rNewColor ); + if ( aBoxItem.GetBottom() ) + ((SvxBorderLine*)aBoxItem.GetBottom())->SetColor( rNewColor ); + if ( aBoxItem.GetLeft() ) + ((SvxBorderLine*)aBoxItem.GetLeft())->SetColor( rNewColor ); + if ( aBoxItem.GetRight() ) + ((SvxBorderLine*)aBoxItem.GetRight())->SetColor( rNewColor ); + } + } + } + break; + } + } + if (bDefault && (aBoxItem.GetTop() || aBoxItem.GetBottom() || + aBoxItem.GetLeft() || aBoxItem.GetRight())) + { + aBoxItem.SetDistance(MIN_BORDER_DIST); + } + aFrameSet.Put( aBoxItem ); + // Vorlagen-AutoUpdate + SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); + if(pFmt && pFmt->IsAutoUpdateFmt()) + { + rSh.AutoUpdateFrame(pFmt, aFrameSet); + } + else + rSh.SetFlyFrmAttr( aFrameSet ); + +} + + + +void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine) +{ + if(pBorderLine->GetInWidth() > rBorderLine.GetInWidth()) + rBorderLine.SetInWidth(pBorderLine->GetInWidth()); + + if(pBorderLine->GetOutWidth() > rBorderLine.GetOutWidth()) + rBorderLine.SetOutWidth(pBorderLine->GetOutWidth()); + + if(pBorderLine->GetDistance() > rBorderLine.GetDistance()) + rBorderLine.SetDistance(pBorderLine->GetDistance()); + + rBorderLine.SetColor(pBorderLine->GetColor()); +} + + + +void SwFrameShell::GetLineStyleState(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; + + if (bParentCntProt) + { + if (rSh.IsFrmSelected()) + rSet.DisableItem( SID_FRAME_LINECOLOR ); + + rSet.DisableItem( SID_ATTR_BORDER ); + rSet.DisableItem( SID_FRAME_LINESTYLE ); + } + else + { + if (rSh.IsFrmSelected()) + { + SfxItemSet aFrameSet( rSh.GetAttrPool(), RES_BOX, RES_BOX ); + + rSh.GetFlyFrmAttr(aFrameSet); + + const SvxBorderLine* pLine = ((const SvxBoxItem&)aFrameSet.Get(RES_BOX)).GetTop(); + rSet.Put(SvxColorItem(pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR)); + } + } +} + +void SwFrameShell::StateInsert(SfxItemSet &rSet) +{ + const int nSel = GetShell().GetSelectionType(); + + if ((nSel & nsSelectionType::SEL_GRF) || (nSel & nsSelectionType::SEL_OLE)) + rSet.DisableItem(FN_INSERT_FRAME); +} diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx new file mode 100644 index 000000000000..037758450081 --- /dev/null +++ b/sw/source/ui/shells/grfsh.cxx @@ -0,0 +1,707 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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" + + + + +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#include <hintids.hxx> +#include <tools/urlobj.hxx> +#include <vcl/msgbox.hxx> +#include <svl/stritem.hxx> +#include <svl/whiter.hxx> +#include <svl/urihelper.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/dispatch.hxx> + +#include <sfx2/objface.hxx> +#include <editeng/sizeitem.hxx> +#include <editeng/protitem.hxx> +#include <sfx2/request.hxx> +#include <svl/srchitem.hxx> +#include <svx/htmlmode.hxx> +#include <svx/sdgluitm.hxx> +#include <svx/sdgcoitm.hxx> +#include <svx/sdggaitm.hxx> +#include <svx/sdgtritm.hxx> +#include <svx/sdginitm.hxx> +#include <svx/sdgmoitm.hxx> +#include <editeng/brshitem.hxx> +#include <svx/grfflt.hxx> +#include <svx/tbxcolor.hxx> +#include <fmturl.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <viewopt.hxx> +#include <swmodule.hxx> +#include <frmatr.hxx> +#include <swundo.hxx> +#include <uitool.hxx> +#include <docsh.hxx> +#include <grfsh.hxx> +#include <frmmgr.hxx> +#include <frmdlg.hxx> +#include <frmfmt.hxx> +#include <grfatr.hxx> +#include <usrpref.hxx> +#include <edtwin.hxx> +#include <swwait.hxx> +#include <shells.hrc> +#include <popup.hrc> + +#define SwGrfShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" + +#include "swabstdlg.hxx" + +#define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) ) + +SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_GRAFIK_TOOLBOX)); +} + +void SwGrfShell::Execute(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + + USHORT nSlot = rReq.GetSlot(); + switch(nSlot) + { + case SID_TWAIN_TRANSFER: + { + GetView().ExecuteScan( rReq ); + break; + } + case FN_SAVE_GRAPHIC: + { + const Graphic *pGraphic; + if(0 != (pGraphic = rSh.GetGraphic())) + { + String sGrfNm, sFilterNm; + rSh.GetGrfNms( &sGrfNm, &sFilterNm ); + ExportGraphic( *pGraphic, sGrfNm ); + } + } + break; + case SID_INSERT_GRAPHIC: + case FN_FORMAT_GRAFIC_DLG: + { + SwFlyFrmAttrMgr aMgr( FALSE, &rSh, rSh.IsFrmSelected() ? + FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF); + const SwViewOption* pVOpt = rSh.GetViewOptions(); + SwViewOption aUsrPref( *pVOpt ); + + SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + SID_ATTR_GRAF_KEEP_ZOOM, SID_ATTR_GRAF_KEEP_ZOOM, + SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE, + SID_ATTR_GRAF_FRMSIZE_PERCENT, SID_ATTR_GRAF_FRMSIZE_PERCENT, + SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC, + FN_PARAM_GRF_CONNECT, FN_PARAM_GRF_CONNECT, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + FN_GET_PRINT_AREA, FN_GET_PRINT_AREA, + FN_SET_FRM_NAME, FN_KEEP_ASPECT_RATIO, + FN_PARAM_GRF_DIALOG, FN_PARAM_GRF_DIALOG, + SID_DOCFRAME, SID_DOCFRAME, + SID_HTML_MODE, SID_HTML_MODE, + FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME, + 0); + + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode)); + FieldUnit eMetric = ::GetDfltMetric((0 != (nHtmlMode&HTMLMODE_ON))); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) ); + + const SwRect* pRect = &rSh.GetAnyCurRect(RECT_PAGE); + SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, pRect->Width(), pRect->Height()); + aFrmSize.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE ) ); + aSet.Put( aFrmSize ); + + aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName())); + if ( nSlot == FN_FORMAT_GRAFIC_DLG ) + { + // --> OD 2009-07-13 #i73249# +// aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText())); + aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) ); + // <-- + } + + pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT); + aFrmSize.SetWidth( pRect->Width() ); + aFrmSize.SetHeight( pRect->Height() ); + aFrmSize.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA) ); + aSet.Put( aFrmSize ); + + aSet.Put( aMgr.GetAttrSet() ); + aSet.SetParent( aMgr.GetAttrSet().GetParent() ); + + // Bei %-Werten Groesse initialisieren + SwFmtFrmSize aSizeCopy = (const SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE); + if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff) + aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width()); + if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff) + aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height()); + + // and now set the size for "external" tabpages + { + SvxSizeItem aSzItm( SID_ATTR_GRAF_FRMSIZE, aSizeCopy.GetSize() ); + aSet.Put( aSzItm ); + + Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() ); + if( 0xff == aSz.Width() ) aSz.Width() = 0; + if( 0xff == aSz.Height() ) aSz.Height() = 0; + + aSzItm.SetSize( aSz ); + aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT ); + aSet.Put( aSzItm ); + } + + String sGrfNm, sFilterNm; + rSh.GetGrfNms( &sGrfNm, &sFilterNm ); + if( sGrfNm.Len() ) + { + aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm, + INET_HEX_ESCAPE, + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + sFilterNm, GPOS_LT, + SID_ATTR_GRAF_GRAPHIC )); + } + else + { + // --> OD 2005-02-09 #119353# - robust + const GraphicObject* pGrfObj = rSh.GetGraphicObj(); + if ( pGrfObj ) + { + aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT, + SID_ATTR_GRAF_GRAPHIC ) ); + } + // <-- + } + aSet.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT, sGrfNm.Len() > 0 ) ); + + // get Mirror and Crop + { + SfxItemSet aTmpSet( rSh.GetAttrPool(), + RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF ); + + rSh.GetCurAttr( aTmpSet ); + aSet.Put( aTmpSet ); + } + + aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, aUsrPref.IsKeepRatio())); + aSet.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM, aUsrPref.IsGrfKeepZoom())); + + aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame())); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_GRF, + GetView().GetViewFrame(), + GetView().GetWindow(), + aSet, FALSE, DLG_FRM_GRF); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if( pDlg->Execute() ) + { + rSh.StartAllAction(); + rSh.StartUndo(UNDO_START); + const SfxPoolItem* pItem; + SfxItemSet* pSet = (SfxItemSet*)pDlg->GetOutputItemSet(); + rReq.Done(*pSet); + // change the 2 frmsize SizeItems to the correct SwFrmSizeItem + if( SFX_ITEM_SET == pSet->GetItemState( + SID_ATTR_GRAF_FRMSIZE, FALSE, &pItem )) + { + SwFmtFrmSize aSize; + const Size& rSz = ((SvxSizeItem*)pItem)->GetSize(); + aSize.SetWidth( rSz.Width() ); + aSize.SetHeight( rSz.Height() ); + + if( SFX_ITEM_SET == pSet->GetItemState( + SID_ATTR_GRAF_FRMSIZE_PERCENT, FALSE, &pItem )) + { + const Size& rRelativeSize = ((SvxSizeItem*)pItem)->GetSize(); + aSize.SetWidthPercent( static_cast< BYTE >( rRelativeSize.Width() ) ); + aSize.SetHeightPercent( static_cast< BYTE >( rRelativeSize.Height() ) ); + } + pSet->Put( aSize ); + } + + // Vorlagen-AutoUpdate + SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); + if(pFmt && pFmt->IsAutoUpdateFmt()) + { + pFmt->SetFmtAttr(*pSet); + SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE, + RES_SURROUND, RES_SURROUND, + RES_ANCHOR, RES_ANCHOR, + RES_VERT_ORIENT,RES_HORI_ORIENT, + 0); + aShellSet.Put(*pSet); + aMgr.SetAttrSet(aShellSet); + } + else + { + aMgr.SetAttrSet(*pSet); + } + aMgr.UpdateFlyFrm(); + + BOOL bApplyUsrPref = FALSE; + if (SFX_ITEM_SET == pSet->GetItemState( + FN_KEEP_ASPECT_RATIO, TRUE, &pItem )) + { + aUsrPref.SetKeepRatio( + ((const SfxBoolItem*)pItem)->GetValue() ); + bApplyUsrPref = TRUE; + } + if( SFX_ITEM_SET == pSet->GetItemState( + SID_ATTR_GRAF_KEEP_ZOOM, TRUE, &pItem )) + { + aUsrPref.SetGrfKeepZoom( + ((const SfxBoolItem*)pItem)->GetValue() ); + bApplyUsrPref = TRUE; + } + + if( bApplyUsrPref ) + SW_MOD()->ApplyUsrPref(aUsrPref, &GetView()); + + // and now set all the graphic attributes and other stuff + if( SFX_ITEM_SET == pSet->GetItemState( + SID_ATTR_GRAF_GRAPHIC, TRUE, &pItem )) + { + if( ((SvxBrushItem*)pItem)->GetGraphicLink() ) + sGrfNm = *((SvxBrushItem*)pItem)->GetGraphicLink(); + else + sGrfNm.Erase(); + + if( ((SvxBrushItem*)pItem)->GetGraphicFilter() ) + sFilterNm = *((SvxBrushItem*)pItem)->GetGraphicFilter(); + else + sFilterNm.Erase(); + + if( sGrfNm.Len() ) + { + SwDocShell* pDocSh = GetView().GetDocShell(); + SwWait aWait( *pDocSh, TRUE ); + SfxMedium* pMedium = pDocSh->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + rSh.ReRead( URIHelper::SmartRel2Abs( + aAbs, sGrfNm, + URIHelper::GetMaybeFileHdl() ), + sFilterNm, 0 ); + } + } + if ( SFX_ITEM_SET == pSet->GetItemState( + FN_SET_FRM_ALT_NAME, TRUE, &pItem )) + { + // --> OD 2009-07-13 #i73249# +// rSh.SetAlternateText( +// ((const SfxStringItem*)pItem)->GetValue() ); + rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() ); + // <-- + } + + SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN, + RES_GRFATR_END-1 ); + aGrfSet.Put( *pSet ); + if( aGrfSet.Count() ) + rSh.SetAttr( aGrfSet ); + + rSh.EndUndo(UNDO_END); + rSh.EndAllAction(); + } + delete pDlg; + } + break; + + case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES: + { + SfxItemSet aSet(rSh.GetAttrPool(), RES_GRFATR_MIRRORGRF, RES_GRFATR_MIRRORGRF); + rSh.GetCurAttr( aSet ); + SwMirrorGrf aGrf((const SwMirrorGrf &)aSet.Get(RES_GRFATR_MIRRORGRF)); + aGrf.SetGrfToggle(!aGrf.IsGrfToggle()); + rSh.SetAttr(aGrf); + } + break; + + default: + ASSERT(!this, falscher Dispatcher); + return; + } +} + + +void SwGrfShell::ExecAttr( SfxRequest &rReq ) +{ + USHORT nGrfType; + if( CNT_GRF == GetShell().GetCntType() && + ( GRAPHIC_BITMAP == ( nGrfType = GetShell().GetGraphicType()) || + GRAPHIC_GDIMETAFILE == nGrfType )) + { + SfxItemSet aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN, + RES_GRFATR_END -1 ); + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + USHORT nSlot = rReq.GetSlot(); + if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, FALSE, &pItem )) + pItem = 0; + + switch( nSlot ) + { + case FN_FLIP_VERT_GRAFIC: + case FN_FLIP_HORZ_GRAFIC: + { + GetShell().GetCurAttr( aGrfSet ); + SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get( + RES_GRFATR_MIRRORGRF ) ); + USHORT nMirror = aMirror.GetValue(); + if( FN_FLIP_VERT_GRAFIC == nSlot ) + switch( nMirror ) + { + case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT; + break; + case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_BOTH; + break; + case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_DONT; + break; + case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_HOR; + break; + } + else + switch( nMirror ) + { + case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_HOR; + break; + case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_BOTH; + break; + case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_DONT; + break; + case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_VERT; + break; + } + aMirror.SetValue( nMirror ); + aGrfSet.ClearItem(); + aGrfSet.Put( aMirror ); + } + break; + + case SID_ATTR_GRAF_LUMINANCE: + if( pItem ) + aGrfSet.Put( SwLuminanceGrf( + ((SfxInt16Item*)pItem)->GetValue() )); + break; + case SID_ATTR_GRAF_CONTRAST: + if( pItem ) + aGrfSet.Put( SwContrastGrf( + ((SfxInt16Item*)pItem)->GetValue() )); + break; + case SID_ATTR_GRAF_RED: + if( pItem ) + aGrfSet.Put( SwChannelRGrf( + ((SfxInt16Item*)pItem)->GetValue() )); + break; + case SID_ATTR_GRAF_GREEN: + if( pItem ) + aGrfSet.Put( SwChannelGGrf( + ((SfxInt16Item*)pItem)->GetValue() )); + break; + case SID_ATTR_GRAF_BLUE: + if( pItem ) + aGrfSet.Put( SwChannelBGrf( + ((SfxInt16Item*)pItem)->GetValue() )); + break; + case SID_ATTR_GRAF_GAMMA: + if( pItem ) + { + double fVal = ((SfxUInt32Item*)pItem)->GetValue(); + aGrfSet.Put( SwGammaGrf(fVal/100. )); + } + break; + case SID_ATTR_GRAF_TRANSPARENCE: + if( pItem ) + aGrfSet.Put( SwTransparencyGrf( + static_cast< sal_Int8 >( ( (SfxUInt16Item*)pItem )->GetValue() ) ) ); + break; + case SID_ATTR_GRAF_INVERT: + if( pItem ) + aGrfSet.Put( SwInvertGrf( + ((SfxBoolItem*)pItem)->GetValue() )); + break; + + case SID_ATTR_GRAF_MODE: + if( pItem ) + aGrfSet.Put( SwDrawModeGrf( + ((SfxUInt16Item*)pItem)->GetValue() )); + break; + + case SID_COLOR_SETTINGS: + { + svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); + aToolboxAccess.toggleToolbox(); + break; + } + case SID_GRFFILTER: + case SID_GRFFILTER_INVERT: + case SID_GRFFILTER_SMOOTH: + case SID_GRFFILTER_SHARPEN: + case SID_GRFFILTER_REMOVENOISE: + case SID_GRFFILTER_SOBEL: + case SID_GRFFILTER_MOSAIC: + case SID_GRFFILTER_EMBOSS: + case SID_GRFFILTER_POSTER: + case SID_GRFFILTER_POPART: + case SID_GRFFILTER_SEPIA: + case SID_GRFFILTER_SOLARIZE: + if( GRAPHIC_BITMAP == nGrfType ) + { + // --> OD 2005-02-09 #119353# - robust + const GraphicObject* pFilterObj( GetShell().GetGraphicObj() ); + if ( pFilterObj ) + { + GraphicObject aFilterObj( *pFilterObj ); + if( SVX_GRAPHICFILTER_ERRCODE_NONE == + SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj )) + GetShell().ReRead( aEmptyStr, aEmptyStr, + &aFilterObj.GetGraphic() ); + } + // <-- + } + break; + + default: + ASSERT(!this, falscher Dispatcher); + } + if( aGrfSet.Count() ) + GetShell().SetAttr( aGrfSet ); + } + GetView().GetViewFrame()->GetBindings().Invalidate(rReq.GetSlot()); +} + +void SwGrfShell::GetAttrState(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + SfxItemSet aCoreSet( GetPool(), aNoTxtNodeSetRange ); + rSh.GetCurAttr( aCoreSet ); + BOOL bParentCntProt = 0 != rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ); + BOOL bIsGrfCntnt = CNT_GRF == GetShell().GetCntType(); + // --> OD 2006-11-03 #i59688# +// BOOL bSwappedOut = rSh.IsGrfSwapOut( TRUE ); +// BOOL bBitmapType = !bSwappedOut && GRAPHIC_BITMAP == rSh.GetGraphicType(); + // <-- + + SetGetStateSet( &rSet ); + + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while( nWhich ) + { + BOOL bDisable = bParentCntProt; + switch( nWhich ) + { + case SID_INSERT_GRAPHIC: + case FN_FORMAT_GRAFIC_DLG: + case SID_TWAIN_TRANSFER: + if( bParentCntProt || !bIsGrfCntnt ) + bDisable = TRUE; + break; + case FN_SAVE_GRAPHIC: + if( rSh.GetGraphicType() == GRAPHIC_NONE ) + bDisable = sal_True; + break; + case SID_COLOR_SETTINGS: + { + if ( bParentCntProt || !bIsGrfCntnt ) + bDisable = TRUE; + else + { + svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); + rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) ); + } + break; + } + + case FN_FLIP_VERT_GRAFIC: + if( !bParentCntProt ) + { + MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get( + RES_GRFATR_MIRRORGRF )).GetValue()); + + rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_VERT || + nState == RES_MIRROR_GRAPH_BOTH)); + } + break; + + case FN_FLIP_HORZ_GRAFIC: + if( !bParentCntProt ) + { + MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get( + RES_GRFATR_MIRRORGRF )).GetValue()); + + rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_HOR || + nState == RES_MIRROR_GRAPH_BOTH)); + } + break; + + + case SID_ATTR_GRAF_LUMINANCE: + if( !bParentCntProt ) + rSet.Put( SfxInt16Item( nWhich, ((SwLuminanceGrf&) + aCoreSet.Get(RES_GRFATR_LUMINANCE)).GetValue() )); + break; + case SID_ATTR_GRAF_CONTRAST: + if( !bParentCntProt ) + rSet.Put( SfxInt16Item( nWhich, ((SwContrastGrf&) + aCoreSet.Get(RES_GRFATR_CONTRAST)).GetValue() )); + break; + case SID_ATTR_GRAF_RED: + if( !bParentCntProt ) + rSet.Put( SfxInt16Item( nWhich, ((SwChannelRGrf&) + aCoreSet.Get(RES_GRFATR_CHANNELR)).GetValue() )); + break; + case SID_ATTR_GRAF_GREEN: + if( !bParentCntProt ) + rSet.Put( SfxInt16Item( nWhich, ((SwChannelGGrf&) + aCoreSet.Get(RES_GRFATR_CHANNELG)).GetValue() )); + break; + case SID_ATTR_GRAF_BLUE: + if( !bParentCntProt ) + rSet.Put( SfxInt16Item( nWhich, ((SwChannelBGrf&) + aCoreSet.Get(RES_GRFATR_CHANNELB)).GetValue() )); + break; + + case SID_ATTR_GRAF_GAMMA: + if( !bParentCntProt ) + rSet.Put( SfxUInt32Item( nWhich, static_cast< UINT32 >( + ( (SwGammaGrf&)aCoreSet.Get( RES_GRFATR_GAMMA ) ).GetValue() * 100 ) ) ); + break; + case SID_ATTR_GRAF_TRANSPARENCE: + if( !bParentCntProt ) + { + // --> OD 2005-02-09 #119353# - robust + const GraphicObject* pGrfObj = rSh.GetGraphicObj(); + if ( pGrfObj ) + { + if( pGrfObj->IsAnimated() || + GRAPHIC_GDIMETAFILE == pGrfObj->GetType() ) + bDisable = TRUE; + else + rSet.Put( SfxUInt16Item( nWhich, ((SwTransparencyGrf&) + aCoreSet.Get(RES_GRFATR_TRANSPARENCY)).GetValue() )); + } + } + break; + case SID_ATTR_GRAF_INVERT: + if( !bParentCntProt ) + rSet.Put( SfxBoolItem( nWhich, ((SwInvertGrf&) + aCoreSet.Get(RES_GRFATR_INVERT)).GetValue() )); + break; + + case SID_ATTR_GRAF_MODE: + if( !bParentCntProt ) + rSet.Put( SfxUInt16Item( nWhich, ((SwDrawModeGrf&) + aCoreSet.Get(RES_GRFATR_DRAWMODE)).GetValue() )); + break; + + case SID_GRFFILTER: + case SID_GRFFILTER_INVERT: + case SID_GRFFILTER_SMOOTH: + case SID_GRFFILTER_SHARPEN: + case SID_GRFFILTER_REMOVENOISE: + case SID_GRFFILTER_SOBEL: + case SID_GRFFILTER_MOSAIC: + case SID_GRFFILTER_EMBOSS: + case SID_GRFFILTER_POSTER: + case SID_GRFFILTER_POPART: + case SID_GRFFILTER_SEPIA: + case SID_GRFFILTER_SOLARIZE: + { + if( bParentCntProt || !bIsGrfCntnt ) + bDisable = TRUE; + // --> OD 2006-11-03 #i59688# + // load graphic only if type is unknown +// else if( bSwappedOut ) +// { +// rSet.DisableItem( nWhich ); +// if( AddGrfUpdateSlot( nWhich )) +// rSh.GetGraphic(FALSE); // start the loading +// } +// else +// bDisable = !bBitmapType; + else + { + const USHORT eGraphicType( rSh.GetGraphicType() ); + if ( ( eGraphicType == GRAPHIC_NONE || + eGraphicType == GRAPHIC_DEFAULT ) && + rSh.IsGrfSwapOut( TRUE ) ) + { + rSet.DisableItem( nWhich ); + if( AddGrfUpdateSlot( nWhich )) + rSh.GetGraphic(FALSE); // start the loading + } + else + { + bDisable = eGraphicType != GRAPHIC_BITMAP; + } + } + // <-- + } + break; + + default: + bDisable = FALSE; + } + + if( bDisable ) + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } + SetGetStateSet( 0 ); +} + + +SwGrfShell::SwGrfShell(SwView &_rView) : + SwBaseShell(_rView) + +{ + SetName(String::CreateFromAscii("Graphic")); + SetHelpId(SW_GRFSHELL); +} + + + + diff --git a/sw/source/ui/shells/grfshex.cxx b/sw/source/ui/shells/grfshex.cxx new file mode 100644 index 000000000000..fe2e7502a3df --- /dev/null +++ b/sw/source/ui/shells/grfshex.cxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <docary.hxx> +#include <grfsh.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <docary.hxx> +#ifndef _TEXTSH_HXX +#include <textsh.hxx> +#endif +#include <viewopt.hxx> +#include <swundo.hxx> +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif +#include <caption.hxx> +#define _SVSTDARR_STRINGSSORTDTOR +#include <svl/svstdarr.hxx> +#include <svtools/filter.hxx> +#include <svx/htmlmode.hxx> +#ifndef _DOCSH_HXX +#include <docsh.hxx> +#endif +#include <frmfmt.hxx> +#include <frmmgr.hxx> +#include <vcl/msgbox.hxx> +#ifndef _SVX_SVDOMEDIA_HXX +#include <svx/svdomedia.hxx> +#endif +#ifndef _SVX_SVDVIEW_HXX +#include <svx/svdview.hxx> +#endif +#ifndef _SVX_SVDPAGV_HXX +#include <svx/svdpagv.hxx> +#endif +#include <SwStyleNameMapper.hxx> +#include <sfx2/filedlghelper.hxx> +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> +#ifndef _POOLFMT_HRC +#include <poolfmt.hrc> +#endif + +#include <sfx2/request.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/stritem.hxx> +#include <avmedia/mediawindow.hxx> +#include <vcl/svapp.hxx> + +// -> #111827# +#include <SwRewriter.hxx> +#include <undobj.hxx> +#include <comcore.hrc> +// <- #111827# + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ui::dialogs; +using namespace ::sfx2; +using ::rtl::OUString; + +bool SwTextShell::InsertMediaDlg( SfxRequest& rReq ) +{ + ::rtl::OUString aURL; + const SfxItemSet* pReqArgs = rReq.GetArgs(); + Window* pWindow = &GetView().GetViewFrame()->GetWindow(); + bool bAPI = false, bRet = false; + + if( pReqArgs ) + { + const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) ); + + if( pStringItem ) + { + aURL = pStringItem->GetValue(); + bAPI = aURL.getLength(); + } + } + + if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) ) + { + Size aPrefSize; + + if( pWindow ) + pWindow->EnterWait(); + + if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) ) + { + if( pWindow ) + pWindow->LeaveWait(); + + if( !bAPI ) + ::avmedia::MediaWindow::executeFormatErrorBox( pWindow ); + } + else + { + SwWrtShell& rSh = GetShell(); + + if( !rSh.HasDrawView() ) + rSh.MakeDrawView(); + + Size aDocSz( rSh.GetDocSize() ); + const SwRect& rVisArea = rSh.VisArea(); + Point aPos( rVisArea.Center() ); + Size aSize; + + if( rVisArea.Width() > aDocSz.Width()) + aPos.X() = aDocSz.Width() / 2 + rVisArea.Left(); + + if(rVisArea.Height() > aDocSz.Height()) + aPos.Y() = aDocSz.Height() / 2 + rVisArea.Top(); + + if( aPrefSize.Width() && aPrefSize.Height() ) + { + if( pWindow ) + aSize = pWindow->PixelToLogic( aPrefSize, MAP_TWIP ); + else + aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP ); + } + else + aSize = Size( 2835, 2835 ); + + SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) ); + + pObj->setURL( aURL ); + rSh.EnterStdMode(); + rSh.SwFEShell::InsertDrawObj( *pObj, aPos ); + bRet = true; + + if( pWindow ) + pWindow->LeaveWait(); + } + } + + return bRet; +} diff --git a/sw/source/ui/shells/langhelper.cxx b/sw/source/ui/shells/langhelper.cxx new file mode 100755 index 000000000000..3a0fe1421a0c --- /dev/null +++ b/sw/source/ui/shells/langhelper.cxx @@ -0,0 +1,564 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <string.h> + +#include <vcl/window.hxx> + +#include <wrtsh.hxx> + +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editdata.hxx> +#include <editeng/outliner.hxx> +#include <editeng/editview.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/langitem.hxx> + +#include <svl/languageoptions.hxx> +#include <svtools/langtab.hxx> +#include <svl/slstitm.hxx> +#include <svl/svstdarr.hxx> +#include <svl/stritem.hxx> + +#include <ndtxt.hxx> +#include <pam.hxx> +#include <view.hxx> +#include <viewopt.hxx> + +#include "swabstdlg.hxx" + +#include <vcl/msgbox.hxx> + +#include <langhelper.hxx> + +using namespace ::com::sun::star; + +namespace SwLangHelper +{ + USHORT GetLanguageStatus(OutlinerView* pOLV,SfxItemSet& rSet) + { + ESelection aSelection = pOLV->GetSelection(); + EditView& rEditView=pOLV->GetEditView(); + EditEngine* pEditEngine=rEditView.GetEditEngine(); + + // the value of used script types + const USHORT nScriptType =pOLV->GetSelectedScriptType(); + String aScriptTypesInUse( String::CreateFromInt32( nScriptType ) );//pEditEngine->GetScriptType(aSelection) + + SvtLanguageTable aLangTable; + + // get keyboard language + String aKeyboardLang; + LanguageType nLang = LANGUAGE_DONTKNOW; + + Window* pWin = rEditView.GetWindow(); + if(pWin) + nLang = pWin->GetInputLanguage(); + if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) + aKeyboardLang = aLangTable.GetString( nLang ); + + // get the language that is in use + const String aMultipleLanguages = String::CreateFromAscii("*"); + String aCurrentLang = aMultipleLanguages; + SfxItemSet aSet(pOLV->GetAttribs()); + nLang = SwLangHelper::GetCurrentLanguage( aSet,nScriptType ); + if (nLang != LANGUAGE_DONTKNOW) + aCurrentLang = aLangTable.GetString( nLang ); + + // build sequence for status value + uno::Sequence< ::rtl::OUString > aSeq( 4 ); + aSeq[0] = aCurrentLang; + aSeq[1] = aScriptTypesInUse; + aSeq[2] = aKeyboardLang; + aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( pEditEngine, aSelection ); + + // set sequence as status value + SfxStringListItem aItem( SID_LANGUAGE_STATUS ); + aItem.SetStringList( aSeq ); + rSet.Put( aItem, SID_LANGUAGE_STATUS ); + return 0; + } + + bool SetLanguageStatus(OutlinerView* pOLV,SfxRequest &rReq,SwView &rView,SwWrtShell &rSh) + { + bool bRestoreSelection = false; + SfxItemSet aEditAttr(pOLV->GetAttribs()); + ESelection aSelection = pOLV->GetSelection(); + EditView & rEditView = pOLV->GetEditView(); + EditEngine * pEditEngine = rEditView.GetEditEngine(); + + // get the language + String aNewLangTxt; + + SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, SID_LANGUAGE_STATUS , sal_False ); + if (pItem) + aNewLangTxt = pItem->GetValue(); + + //!! Remember the view frame right now... + //!! (call to GetView().GetViewFrame() will break if the + //!! SwTextShell got destroyed meanwhile.) + SfxViewFrame *pViewFrame = rView.GetViewFrame(); + + if (aNewLangTxt.EqualsAscii( "*" )) + { + // open the dialog "Tools/Options/Language Settings - Language" + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + if (pFact) + { + VclAbstractDialog* pDlg = pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS ); + pDlg->Execute(); + delete pDlg; + } + } + else + { + // setting the new language... + if (aNewLangTxt.Len() > 0) + { + const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); + const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); + const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); + const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); + + xub_StrLen nPos = 0; + bool bForSelection = true; + bool bForParagraph = false; + if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) + { + // ... for the current selection + aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); + bForSelection = true; + } + else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) + { + // ... for the current paragraph language + aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); + bForSelection = true; + bForParagraph = true; + } + else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) + { + // ... as default document language + aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); + bForSelection = false; + } + + if (bForParagraph) + { + bRestoreSelection = true; + SwLangHelper::SelectPara( rEditView, aSelection ); + aSelection = pOLV->GetSelection(); + } + if (!bForSelection) // document language to be changed... + { + rSh.StartAction(); + rSh.LockView( TRUE ); + rSh.Push(); + + // prepare to apply new language to all text in document + rSh.SelAll(); + rSh.ExtendedSelectAll(); + } + + if (aNewLangTxt != aStrNone) + SwLangHelper::SetLanguage( rSh, pEditEngine, aSelection, aNewLangTxt, bForSelection, aEditAttr ); + else + SwLangHelper::SetLanguage_None( rSh, pEditEngine, aSelection, bForSelection, aEditAttr ); + + // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks + // when setting a new language attribute + if (bForSelection) + { + const SwViewOption* pVOpt = rView.GetWrtShellPtr()->GetViewOptions(); + ULONG nCntrl = pEditEngine->GetControlWord(); + // turn off + if (!pVOpt->IsOnlineSpell()) + nCntrl &= ~EE_CNTRL_ONLINESPELLING; + else + nCntrl &= ~EE_CNTRL_ONLINESPELLING; + pEditEngine->SetControlWord(nCntrl); + + //turn back on + if (pVOpt->IsOnlineSpell()) + nCntrl |= EE_CNTRL_ONLINESPELLING; + else + nCntrl &= ~EE_CNTRL_ONLINESPELLING; + pEditEngine->SetControlWord(nCntrl); + + pEditEngine->CompleteOnlineSpelling(); + rEditView.Invalidate(); + } + + if (!bForSelection) + { + // need to release view and restore selection... + rSh.Pop( FALSE ); + rSh.LockView( FALSE ); + rSh.EndAction(); + } + } + } + + // invalidate slot to get the new language displayed + pViewFrame->GetBindings().Invalidate( rReq.GetSlot() ); + + rReq.Done(); + return bRestoreSelection; + } + + + void SetLanguage(SwWrtShell &rWrtSh, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet) + { + SetLanguage(rWrtSh,0,ESelection(),rLangText,bIsForSelection,rCoreSet); + } + + void SetLanguage(SwWrtShell &rWrtSh, EditEngine* pEditEngine,ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet) + { + const LanguageType nLang = SvtLanguageTable().GetType( rLangText ); + if (nLang != LANGUAGE_DONTKNOW) + { + USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ); + + //get ScriptType + USHORT nLangWhichId = 0; + bool bIsSingleScriptType = true; + switch (nScriptType) + { + case SCRIPTTYPE_LATIN : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE : RES_CHRATR_LANGUAGE; break; + case SCRIPTTYPE_ASIAN : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE_CJK : RES_CHRATR_CJK_LANGUAGE; break; + case SCRIPTTYPE_COMPLEX : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE_CTL : RES_CHRATR_CTL_LANGUAGE; break; + default: + bIsSingleScriptType = false; + DBG_ERROR( "unexpected case" ); + } + if (bIsSingleScriptType) + { + if (bIsForSelection) + { + // apply language to current selection + if (pEditEngine) + { + rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); + pEditEngine->QuickSetAttribs( rCoreSet, aSelection); + } + else + { + rWrtSh.GetCurAttr( rCoreSet ); + rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); + rWrtSh.SetAttr( rCoreSet ); + } + } + else // change document language + { + // set document default language + switch (nLangWhichId) + { + case EE_CHAR_LANGUAGE : nLangWhichId = RES_CHRATR_LANGUAGE; break; + case EE_CHAR_LANGUAGE_CJK : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break; + case EE_CHAR_LANGUAGE_CTL : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break; + } + rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) ); + + // set respective language attribute in text document to default + // (for all text in the document - which should be selected by now...) + SvUShortsSort aAttribs; + aAttribs.Insert( nLangWhichId ); + rWrtSh.ResetAttr( &aAttribs ); + } + } + } + } + + void SetLanguage_None(SwWrtShell &rWrtSh,bool bIsForSelection, SfxItemSet &rCoreSet ) + { + SetLanguage_None(rWrtSh,0,ESelection(),bIsForSelection,rCoreSet); + } + + void SetLanguage_None(SwWrtShell &rWrtSh, EditEngine* pEditEngine,ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ) + { + // EditEngine IDs + const USHORT aLangWhichId_EE[3] = + { + EE_CHAR_LANGUAGE, + EE_CHAR_LANGUAGE_CJK, + EE_CHAR_LANGUAGE_CTL + }; + + // Writewr IDs + const USHORT aLangWhichId_Writer[3] = + { + RES_CHRATR_LANGUAGE, + RES_CHRATR_CJK_LANGUAGE, + RES_CHRATR_CTL_LANGUAGE + }; + + if (bIsForSelection) + { + // apply language to current selection + if (pEditEngine) + { + for (sal_uInt16 i = 0; i < 3; ++i) + rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_EE[i] )); + pEditEngine->QuickSetAttribs( rCoreSet, aSelection); + } + else + { + rWrtSh.GetCurAttr( rCoreSet ); + for (sal_uInt16 i = 0; i < 3; ++i) + rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] )); + rWrtSh.SetAttr( rCoreSet ); + } + } + else // change document language + { + SvUShortsSort aAttribs; + for (sal_uInt16 i = 0; i < 3; ++i) + { + rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] ) ); + aAttribs.Insert( aLangWhichId_Writer[i] ); + } + + // set all language attributes to default + // (for all text in the document - which should be selected by now...) + rWrtSh.ResetAttr( &aAttribs ); + } + } + + /// @returns : the language for the selected text that is set for the + /// specified attribute (script type). + /// If there are more than one languages used LANGUAGE_DONTKNOW will be returned. + /// @param nLangWhichId : one of + /// RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, + LanguageType GetLanguage( SwWrtShell &rSh, USHORT nLangWhichId ) + { + SfxItemSet aSet( rSh.GetAttrPool(), nLangWhichId, nLangWhichId ); + rSh.GetCurAttr( aSet ); + + return GetLanguage(aSet,nLangWhichId); + } + + LanguageType GetLanguage( SfxItemSet aSet, USHORT nLangWhichId ) + { + + LanguageType nLang = LANGUAGE_SYSTEM; + + const SfxPoolItem *pItem = 0; + SfxItemState nState = aSet.GetItemState( nLangWhichId, TRUE, &pItem ); + if (nState > SFX_ITEM_DEFAULT && pItem) + { + // the item is set and can be used + nLang = (dynamic_cast< const SvxLanguageItem* >(pItem))->GetLanguage(); + } + else if (nState == SFX_ITEM_DEFAULT) + { + // since the attribute is not set: retrieve the default value + nLang = (dynamic_cast< const SvxLanguageItem& >(aSet.GetPool()->GetDefaultItem( nLangWhichId ))).GetLanguage(); + } + else if (nState == SFX_ITEM_DONTCARE) + { + // there is more than one language... + nLang = LANGUAGE_DONTKNOW; + } + DBG_ASSERT( nLang != LANGUAGE_SYSTEM, "failed to get the language?" ); + + return nLang; + } + + /// @returns: the language in use for the selected text. + /// 'In use' means the language(s) matching the script type(s) of the + /// selected text. Or in other words, the language a spell checker would use. + /// If there is more than one language LANGUAGE_DONTKNOW will be returned. + LanguageType GetCurrentLanguage( SwWrtShell &rSh ) + { + // get all script types used in current selection + const USHORT nScriptType = rSh.GetScriptType(); + + //set language attribute to use according to the script type + USHORT nLangWhichId = 0; + bool bIsSingleScriptType = true; + switch (nScriptType) + { + case SCRIPTTYPE_LATIN : nLangWhichId = RES_CHRATR_LANGUAGE; break; + case SCRIPTTYPE_ASIAN : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break; + case SCRIPTTYPE_COMPLEX : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break; + default: bIsSingleScriptType = false; break; + } + + // get language according to the script type(s) in use + LanguageType nCurrentLang = LANGUAGE_SYSTEM; + if (bIsSingleScriptType) + nCurrentLang = GetLanguage( rSh, nLangWhichId ); + else + { + // check if all script types are set to LANGUAGE_NONE and return + // that if this is the case. Otherwise, having multiple script types + // in use always means there are several languages in use... + const USHORT aScriptTypes[3] = + { + RES_CHRATR_LANGUAGE, + RES_CHRATR_CJK_LANGUAGE, + RES_CHRATR_CTL_LANGUAGE + }; + nCurrentLang = LANGUAGE_NONE; + for (sal_uInt16 i = 0; i < 3; ++i) + { + LanguageType nTmpLang = GetLanguage( rSh, aScriptTypes[i] ); + if (nTmpLang != LANGUAGE_NONE) + { + nCurrentLang = LANGUAGE_DONTKNOW; + break; + } + } + } + DBG_ASSERT( nCurrentLang != LANGUAGE_SYSTEM, "failed to get the language?" ); + + return nCurrentLang; + } + + /// @returns: the language in use for the selected text. + /// 'In use' means the language(s) matching the script type(s) of the + /// selected text. Or in other words, the language a spell checker would use. + /// If there is more than one language LANGUAGE_DONTKNOW will be returned. + LanguageType GetCurrentLanguage(SfxItemSet aSet,USHORT nScriptType ) + { + //set language attribute to use according to the script type + USHORT nLangWhichId = 0; + bool bIsSingleScriptType = true; + switch (nScriptType) + { + case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE; break; + case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; + case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + default: bIsSingleScriptType = false; + } + + // get language according to the script type(s) in use + LanguageType nCurrentLang = LANGUAGE_SYSTEM; + if (bIsSingleScriptType) + nCurrentLang = GetLanguage( aSet, nLangWhichId ); + else + { + // check if all script types are set to LANGUAGE_NONE and return + // that if this is the case. Otherwise, having multiple script types + // in use always means there are several languages in use... + const USHORT aScriptTypes[3] = + { + EE_CHAR_LANGUAGE, + EE_CHAR_LANGUAGE_CJK, + EE_CHAR_LANGUAGE_CTL + }; + nCurrentLang = LANGUAGE_NONE; + for (sal_uInt16 i = 0; i < 3; ++i) + { + LanguageType nTmpLang = GetLanguage( aSet, aScriptTypes[i] ); + if (nTmpLang != LANGUAGE_NONE) + { + nCurrentLang = LANGUAGE_DONTKNOW; + break; + } + } + } + DBG_ASSERT( nCurrentLang != LANGUAGE_SYSTEM, "failed to get the language?" ); + + return nCurrentLang; + } + + String GetTextForLanguageGuessing( SwWrtShell &rSh ) + { + // string for guessing language + String aText; + SwPaM *pCrsr = rSh.GetCrsr(); + SwTxtNode *pNode = pCrsr->GetNode()->GetTxtNode(); + if (pNode) + { + aText = pNode->GetTxt(); + if (aText.Len() > 0) + { + xub_StrLen nStt = 0; + xub_StrLen nEnd = pCrsr->GetPoint()->nContent.GetIndex(); + // at most 100 chars to the left... + nStt = nEnd > 100 ? nEnd - 100 : 0; + // ... and 100 to the right of the cursor position + nEnd = aText.Len() - nEnd > 100 ? nEnd + 100 : aText.Len(); + aText = aText.Copy( nStt, nEnd - nStt ); + } + } + return aText; + } + + String GetTextForLanguageGuessing(EditEngine* rEditEngine, ESelection aDocSelection ) + { + // string for guessing language + String aText; + + aText = rEditEngine->GetText(aDocSelection); + if (aText.Len() > 0) + { + xub_StrLen nStt = 0; + xub_StrLen nEnd = aDocSelection.nEndPos; + // at most 100 chars to the left... + nStt = nEnd > 100 ? nEnd - 100 : 0; + // ... and 100 to the right of the cursor position + nEnd = aText.Len() - nEnd > 100 ? nEnd + 100 : aText.Len(); + aText = aText.Copy( nStt, nEnd - nStt ); + } + + return aText; + } + + + void SelectPara( EditView &rEditView, const ESelection &rCurSel ) + { + ESelection aParaSel( rCurSel.nStartPara, 0, rCurSel.nStartPara, USHRT_MAX ); + rEditView.SetSelection( aParaSel ); + } + + void SelectCurrentPara( SwWrtShell &rWrtSh ) + { + // select current para + if (!rWrtSh.IsSttPara()) + rWrtSh.MovePara( fnParaCurr, fnParaStart ); + if (!rWrtSh.HasMark()) + rWrtSh.SetMark(); + rWrtSh.SwapPam(); + if (!rWrtSh.IsEndPara()) + rWrtSh.MovePara( fnParaCurr, fnParaEnd ); + #if OSL_DEBUG_LEVEL > 1 + String aSelTxt; + rWrtSh.GetSelectedText( aSelTxt ); + (void) aSelTxt; + #endif + } +} + diff --git a/sw/source/ui/shells/listsh.cxx b/sw/source/ui/shells/listsh.cxx new file mode 100644 index 000000000000..24a8c12d992b --- /dev/null +++ b/sw/source/ui/shells/listsh.cxx @@ -0,0 +1,295 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 "cmdid.h" +#include "hintids.hxx" +#include <editeng/sizeitem.hxx> +#include <editeng/brshitem.hxx> +#include <sfx2/app.hxx> +#include <sfx2/request.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/bindings.hxx> +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> +#include <tools/urlobj.hxx> +#include <svl/whiter.hxx> +#include <svl/intitem.hxx> +#include <tools/shl.hxx> +#include <svl/srchitem.hxx> + +// --> FME 2005-01-04 #i35572# +#include <numrule.hxx> +// <-- +#include <fmtornt.hxx> +#include "wrtsh.hxx" +#include "swmodule.hxx" +#include "frmatr.hxx" +#include "helpid.h" +#include "globals.hrc" +#include "shells.hrc" +#include "uinums.hxx" +#include "listsh.hxx" +#include "poolfmt.hxx" +#include "view.hxx" +#include "edtwin.hxx" + +#define SwListShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" + +#include <IDocumentOutlineNodes.hxx> + +SFX_IMPL_INTERFACE(SwListShell, SwBaseShell, SW_RES(STR_SHELLNAME_LIST)) +{ + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_NUM_TOOLBOX)); +} + + +TYPEINIT1(SwListShell,SwBaseShell) + +// --> FME 2005-01-04 #i35572# Functionality of Numbering/Bullet toolbar +// for outline numbered paragraphs should match the functions for outlines +// available in the navigator. Therefore the code in the following +// function is quite similar the the code in SwContentTree::ExecCommand. +void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp ) +{ + const sal_uInt16 nActPos = rSh.GetOutlinePos(); + if ( nActPos < USHRT_MAX && rSh.IsOutlineMovable( nActPos ) ) + { + rSh.Push(); + rSh.MakeOutlineSel( nActPos, nActPos, TRUE ); + + if ( bMove ) + { + const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() ); + const sal_uInt16 nActLevel = static_cast<sal_uInt16>(pIDoc->getOutlineLevel( nActPos )); + sal_uInt16 nActEndPos = nActPos + 1; + sal_Int16 nDir = 0; + + if ( !bUp ) + { + // Move down with subpoints: + while ( nActEndPos < pIDoc->getOutlineNodesCount() && + pIDoc->getOutlineLevel( nActEndPos ) > nActLevel ) + ++nActEndPos; + + if ( nActEndPos < pIDoc->getOutlineNodesCount() ) + { + // The current subpoint which should be moved + // starts at nActPos and ends at nActEndPos - 1 + --nActEndPos; + sal_uInt16 nDest = nActEndPos + 2; + while ( nDest < pIDoc->getOutlineNodesCount() && + pIDoc->getOutlineLevel( nDest ) > nActLevel ) + ++nDest; + + nDir = nDest - 1 - nActEndPos; + } + } + else + { + // Move up with subpoints: + if ( nActPos > 0 ) + { + --nActEndPos; + sal_uInt16 nDest = nActPos - 1; + while ( nDest > 0 && pIDoc->getOutlineLevel( nDest ) > nActLevel ) + --nDest; + + nDir = nDest - nActPos; + } + } + + if ( nDir ) + { + rSh.MoveOutlinePara( nDir ); + rSh.GotoOutline( nActPos + nDir ); + } + } + else + { + // Up/down with subpoints: + rSh.OutlineUpDown( bUp ? -1 : 1 ); + } + + rSh.ClearMark(); + rSh.Pop( sal_False ); + } +} +// <-- + +void SwListShell::Execute(SfxRequest &rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + SwWrtShell& rSh = GetShell(); + + // --> FME 2005-01-04 #i35572# + const SwNumRule* pCurRule = rSh.GetCurNumRule(); + ASSERT( pCurRule, "SwListShell::Execute without NumRule" ) + bool bOutline = pCurRule && pCurRule->IsOutlineRule(); + // <-- + + switch (nSlot) + { + case FN_NUM_BULLET_DOWN: + case FN_NUM_BULLET_UP: + { + SfxViewFrame * pFrame = GetView().GetViewFrame(); + + rReq.Done(); + rSh.NumUpDown( ( nSlot == FN_NUM_BULLET_DOWN ) + ? TRUE + : FALSE ); + pFrame->GetBindings().Invalidate( SID_TABLE_CELL ); // StatusZeile updaten! + } + break; + + case FN_NUM_BULLET_NEXT: + rSh.GotoNextNum(); + rReq.Done(); + break; + + case FN_NUM_BULLET_NONUM: + rSh.NoNum(); + rReq.Done(); + break; + + case FN_NUM_BULLET_OFF: + { + rReq.Ignore(); + SfxRequest aReq( GetView().GetViewFrame(), FN_NUM_BULLET_ON ); + aReq.AppendItem( SfxBoolItem( FN_PARAM_1, FALSE ) ); + aReq.Done(); + rSh.DelNumRules(); + break; + } + + case FN_NUM_BULLET_OUTLINE_DOWN: + if ( bOutline ) + lcl_OutlineUpDownWithSubPoints( rSh, false, false ); + else + rSh.MoveNumParas(FALSE, FALSE); + rReq.Done(); + break; + + case FN_NUM_BULLET_OUTLINE_MOVEDOWN: + if ( bOutline ) + lcl_OutlineUpDownWithSubPoints( rSh, true, false ); + else + rSh.MoveNumParas(TRUE, FALSE); + rReq.Done(); + break; + + case FN_NUM_BULLET_OUTLINE_MOVEUP: + if ( bOutline ) + lcl_OutlineUpDownWithSubPoints( rSh, true, true ); + else + rSh.MoveNumParas(TRUE, TRUE); + rReq.Done(); + break; + + case FN_NUM_BULLET_OUTLINE_UP: + if ( bOutline ) + lcl_OutlineUpDownWithSubPoints( rSh, false, true ); + else + rSh.MoveNumParas(FALSE, TRUE); + rReq.Done(); + break; + + case FN_NUM_BULLET_PREV: + rSh.GotoPrevNum(); + rReq.Done(); + break; + + case FN_NUM_OR_NONUM: + { + BOOL bApi = rReq.IsAPI(); + BOOL bDelete = !rSh.IsNoNum(!bApi); + if(pArgs ) + bDelete = ((SfxBoolItem &)pArgs->Get(rReq.GetSlot())).GetValue(); + rSh.NumOrNoNum( bDelete, !bApi ); + rReq.AppendItem( SfxBoolItem( nSlot, bDelete ) ); + rReq.Done(); + } + break; + default: + ASSERT(!this, falscher Dispatcher); + return; + } +} + + +void SwListShell::GetState(SfxItemSet &rSet) +{ + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + SwWrtShell& rSh = GetShell(); + BYTE nCurrentNumLevel = rSh.GetNumLevel(); + while ( nWhich ) + { + switch( nWhich ) + { + case FN_NUM_OR_NONUM: + rSet.Put(SfxBoolItem(nWhich, GetShell().IsNoNum(FALSE))); + break; + case FN_NUM_BULLET_OUTLINE_UP: + case FN_NUM_BULLET_UP: + if(!nCurrentNumLevel) + rSet.DisableItem(nWhich); + break; + case FN_NUM_BULLET_OUTLINE_DOWN : + { + sal_uInt8 nUpper = 0; + sal_uInt8 nLower = 0; + rSh.GetCurrentOutlineLevels( nUpper, nLower ); + if(nLower == (MAXLEVEL - 1)) + rSet.DisableItem(nWhich); + } + break; + case FN_NUM_BULLET_DOWN: + if(nCurrentNumLevel == (MAXLEVEL - 1)) + rSet.DisableItem(nWhich); + break; + } + nWhich = aIter.NextWhich(); + } +} + + +SwListShell::SwListShell(SwView &_rView) : + SwBaseShell(_rView) +{ + SetName(String::CreateFromAscii("List")); + SetHelpId(SW_LISTSHELL); +} + + diff --git a/sw/source/ui/shells/makefile.mk b/sw/source/ui/shells/makefile.mk new file mode 100644 index 000000000000..e9a03a5a41cc --- /dev/null +++ b/sw/source/ui/shells/makefile.mk @@ -0,0 +1,93 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sw +TARGET=shells + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/inc$/sw.mk + +# --- Files -------------------------------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES = \ + shells.src + +SLOFILES = \ + $(SLO)$/langhelper.obj \ + $(SLO)$/annotsh.obj \ + $(SLO)$/basesh.obj \ + $(SLO)$/beziersh.obj \ + $(SLO)$/drawdlg.obj \ + $(SLO)$/drawsh.obj \ + $(SLO)$/drformsh.obj \ + $(SLO)$/drwbassh.obj \ + $(SLO)$/drwtxtex.obj \ + $(SLO)$/drwtxtsh.obj \ + $(SLO)$/frmsh.obj \ + $(SLO)$/grfsh.obj \ + $(SLO)$/grfshex.obj \ + $(SLO)$/mediash.obj \ + $(SLO)$/listsh.obj \ + $(SLO)$/olesh.obj \ + $(SLO)$/slotadd.obj \ + $(SLO)$/tabsh.obj \ + $(SLO)$/textdrw.obj \ + $(SLO)$/textfld.obj \ + $(SLO)$/textglos.obj \ + $(SLO)$/textidx.obj \ + $(SLO)$/textsh.obj \ + $(SLO)$/textsh1.obj \ + $(SLO)$/textsh2.obj \ + $(SLO)$/txtattr.obj \ + $(SLO)$/txtcrsr.obj \ + $(SLO)$/txtnum.obj + +EXCEPTIONSFILES = \ + $(SLO)$/basesh.obj \ + $(SLO)$/annotsh.obj \ + $(SLO)$/drwtxtsh.obj \ + $(SLO)$/textsh.obj \ + $(SLO)$/textsh2.obj \ + $(SLO)$/grfshex.obj \ + $(SLO)$/drawsh.obj \ + $(SLO)$/drwtxtsh.obj \ + $(SLO)$/frmsh.obj \ + $(SLO)$/drwtxtex.obj \ + $(SLO)$/textsh1.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + +$(SRS)$/shells.srs: $(SOLARINCDIR)$/svx$/globlmn.hrc + diff --git a/sw/source/ui/shells/mediash.cxx b/sw/source/ui/shells/mediash.cxx new file mode 100644 index 000000000000..36aa18f2d01c --- /dev/null +++ b/sw/source/ui/shells/mediash.cxx @@ -0,0 +1,222 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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" + + + + +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#include <hintids.hxx> +#include <tools/urlobj.hxx> +#include <vcl/msgbox.hxx> +#include <svl/stritem.hxx> +#include <svl/whiter.hxx> +#include <svl/urihelper.hxx> +#include <sfx2/dispatch.hxx> +#include <editeng/sizeitem.hxx> +#include <editeng/protitem.hxx> +#include <sfx2/request.hxx> +#include <svl/srchitem.hxx> +#include <svx/htmlmode.hxx> +#include <svx/sdgluitm.hxx> +#include <svx/sdgcoitm.hxx> +#include <svx/sdggaitm.hxx> +#include <svx/sdgtritm.hxx> +#include <svx/sdginitm.hxx> +#include <svx/sdgmoitm.hxx> +#include <editeng/brshitem.hxx> +#include <svx/grfflt.hxx> +#include <fmturl.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <viewopt.hxx> +#include <swmodule.hxx> +#include <frmatr.hxx> +#include <swundo.hxx> +#include <uitool.hxx> +#include <docsh.hxx> +#include <mediash.hxx> +#include <frmmgr.hxx> +#include <frmdlg.hxx> +#include <frmfmt.hxx> +#include <grfatr.hxx> +#include <usrpref.hxx> +#include <edtwin.hxx> +#include <swwait.hxx> +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif +#ifndef _POPUP_HRC +#include <popup.hrc> +#endif + +#include <sfx2/objface.hxx> +#include <svx/svdomedia.hxx> +#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx> +#include <avmedia/mediaitem.hxx> + +#define SwMediaShell +#include <sfx2/msg.hxx> +#include "swslots.hxx" +#include "swabstdlg.hxx" + +SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX)); +} + +// ------------------------------------------------------------------------------ + +void SwMediaShell::ExecMedia(SfxRequest &rReq) +{ + SwWrtShell* pSh = &GetShell(); + SdrView* pSdrView = pSh->GetDrawView(); + + if( pSdrView ) + { + const SfxItemSet* pArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + BOOL bChanged = pSdrView->GetModel()->IsChanged(); + + pSdrView->GetModel()->SetChanged( FALSE ); + + switch( nSlotId ) + { + case SID_DELETE: + { + if( pSh->IsObjSelected() ) + { + pSh->SetModified(); + pSh->DelSelectedObj(); + + if( pSh->IsSelFrmMode() ) + pSh->LeaveSelFrmMode(); + + GetView().AttrChangedNotify( pSh ); + } + } + break; + + case( SID_AVMEDIA_TOOLBOX ): + { + if( pSh->IsObjSelected() ) + { + const SfxPoolItem* pItem; + + if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, FALSE, &pItem ) ) ) + pItem = NULL; + + if( pItem ) + { + SdrMarkList* pMarkList = new SdrMarkList( pSdrView->GetMarkedObjectList() ); + + if( 1 == pMarkList->GetMarkCount() ) + { + SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrMediaObj ) ) + { + static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( + static_cast< const ::avmedia::MediaItem& >( *pItem ) ); + } + } + + delete pMarkList; + } + } + } + break; + + default: + break; + } + + if( pSdrView->GetModel()->IsChanged() ) + GetShell().SetModified(); + else if( bChanged ) + pSdrView->GetModel()->SetChanged(TRUE); + } +} + +// ------------------------------------------------------------------------------ + +void SwMediaShell::GetMediaState(SfxItemSet &rSet) +{ + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + while( nWhich ) + { + if( SID_AVMEDIA_TOOLBOX == nWhich ) + { + SwWrtShell& rSh = GetShell(); + SdrView* pView = rSh.GetDrawView(); + bool bDisable = true; + + if( pView ) + { + SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() ); + + if( 1 == pMarkList->GetMarkCount() ) + { + SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrMediaObj ) ) + { + ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX ); + + static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem ); + rSet.Put( aItem ); + bDisable = false; + } + } + + if( bDisable ) + rSet.DisableItem( SID_AVMEDIA_TOOLBOX ); + + delete pMarkList; + } + } + + nWhich = aIter.NextWhich(); + } +} + +// ------------------------------------------------------------------------------ + +SwMediaShell::SwMediaShell(SwView &_rView) : + SwBaseShell(_rView) + +{ + SetName(String::CreateFromAscii("Media Playback")); + SetHelpId(SW_MEDIASHELL); +} diff --git a/sw/source/ui/shells/olesh.cxx b/sw/source/ui/shells/olesh.cxx new file mode 100644 index 000000000000..a4eef5cdbf1d --- /dev/null +++ b/sw/source/ui/shells/olesh.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <sfx2/app.hxx> +#include <sfx2/request.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objitem.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#ifndef _HELPID_H +#include <helpid.h> +#endif +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif +#include <frmsh.hxx> +#ifndef _OLESH_HXX +#include <olesh.hxx> +#endif + +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#ifndef _POPUP_HRC +#include <popup.hrc> +#endif +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif + + +#define SwOleShell +#include <sfx2/msg.hxx> +#include <swslots.hxx> + + +SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell, SW_RES(STR_SHELLNAME_OBJECT)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_OLE_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_OLE_TOOLBOX)); +} + + +SwOleShell::SwOleShell(SwView &_rView) : + SwFrameShell(_rView) + +{ + SetName(String::CreateFromAscii("Object")); + SetHelpId(SW_OLESHELL); +} + + diff --git a/sw/source/ui/shells/shells.src b/sw/source/ui/shells/shells.src new file mode 100644 index 000000000000..7e9a20bb6fc0 --- /dev/null +++ b/sw/source/ui/shells/shells.src @@ -0,0 +1,1139 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ +#include <svx/svxids.hrc> +#include <svx/globlmn.hrc> +#include "toolbox.hrc" +#include "helpid.h" +InfoBox MSG_NO_RULER +{ + BUTTONS = WB_OK ; + DEFBUTTON = WB_DEF_OK ; + Message [ en-US ] = "There are no bitmaps in the Gallery theme 'Rulers'." ; +}; +String STR_GRFILTER_OPENERROR +{ + Text [ en-US ] = "Graphics file cannot be opened" ; + Text [ x-comment ] = " "; +}; +String STR_GRFILTER_IOERROR +{ + Text [ en-US ] = "Graphics file cannot be read" ; + Text [ x-comment ] = " "; +}; +String STR_GRFILTER_FORMATERROR +{ + Text [ en-US ] = "Unknown graphic format" ; + Text [ x-comment ] = " "; +}; +String STR_GRFILTER_VERSIONERROR +{ + Text [ en-US ] = "This graphic file version is not supported" ; + Text [ x-comment ] = " "; +}; +String STR_GRFILTER_FILTERERROR +{ + Text [ en-US ] = "Graphics filter not found" ; + Text [ x-comment ] = " "; +}; +String STR_GRFILTER_TOOBIG +{ + Text [ en-US ] = "Not enough memory to insert the picture." ; + Text [ x-comment ] = " "; +}; +String STR_INSERT_GRAPHIC +{ + Text [ en-US ] = "Insert picture" ; +}; +String STR_NO_ADDRESSBOOK +{ + Text [ en-US ] = "An Address Book does not exist" ; + Text [ x-comment ] = " "; +}; +String STR_NOTIZ_INSERT +{ + Text [ en-US ] = "Insert Note" ; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_COMMENT +{ + Text [ en-US ] = "Comment: " ; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_INSERTED +{ + Text [ en-US ] = "Insertion" ; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_DELETED +{ + Text [ en-US ] = "Deletion" ; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_AUTOFMT +{ + Text [ en-US ] = "AutoCorrect"; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_FORMATED +{ + Text [ en-US ] = "Formats" ; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_TABLECHG +{ + Text [ en-US ] = "Table Changes" ; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_FMTCOLLSET +{ + Text [ en-US ] = "Applied Paragraph Styles"; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_TITLE +{ + Text [ en-US ] = "AutoCorrect"; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_MSG +{ + Text [ en-US ] = "AutoCorrect completed.\nYou can accept or reject all changes,\nor accept or reject particular changes."; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_ACCEPT_ALL +{ + Text [ en-US ] = "Accept All"; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_REJECT_ALL +{ + Text [ en-US ] = "Reject All"; + Text [ x-comment ] = " "; +}; +String STR_REDLINE_EDIT +{ + Text [ en-US ] = "Edit Changes"; + Text [ x-comment ] = " "; +}; +QueryBox DLG_IMPORT_DBNAME +{ + BUTTONS = WB_YES_NO ; + DEFBUTTON = WB_DEF_NO ; + Message [ en-US ] = "Use database name as default database for the document?" ; + Message [ x-comment ] = " "; +}; +String STR_PAGE +{ + Text [ en-US ] = "Page " ; + Text [ x-comment ] = " "; +}; +String RID_TEXT_TOOLBOX +{ + /* ### ACHTUNG: Neuer Text in Resource? Textobjektleiste : Textleiste */ + Text [ en-US ] = "Text Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_TEXT_TOOLBOX +{ + HelpID = HID_TEXT_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + HideWhenDeactivate = TRUE ; + LineSpacing = TRUE ; + Customize = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + ItemList = + { + MN_TEMPLATE + MN_FONT + MN_TEXT1(TRUE) + MN_TEXT1_BLOCK + MN_TEXT_LTR_RTL + MN_TEXT_LINESPACE + MN_TEXT2 + MN_TEXT_BACKGROUND + MN_TEXT_DIALOGS(TRUE) + }; + Scroll = TRUE ; +}; +String RID_TABLE_TOOLBOX +{ + Text [ en-US ] = "Table Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_TABLE_TOOLBOX +{ + HelpID = HID_TABLE_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + Customize = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + Scroll = TRUE ; + ItemList = + { + MN_TEMPLATE + MN_FONT + ToolBoxItem + { + Identifier = FN_TABLE_AUTOSUM ; + HelpID = FN_TABLE_AUTOSUM ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_MODE_FIX ; + HelpID = FN_TABLE_MODE_FIX ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_MODE_FIX_PROP ; + HelpID = FN_TABLE_MODE_FIX_PROP ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_MODE_VARIABLE ; + HelpID = FN_TABLE_MODE_VARIABLE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_MERGE_CELLS ; + HelpID = FN_TABLE_MERGE_CELLS ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_SPLIT_CELLS ; + HelpID = FN_TABLE_SPLIT_CELLS ; + }; + ToolBoxItem + { + DropDown = TRUE ; + Identifier = FN_OPTIMIZE_TABLE ; + HelpID = FN_OPTIMIZE_TABLE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_INSERT_ROW ; + HelpID = FN_TABLE_INSERT_ROW ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_INSERT_COL ; + HelpID = FN_TABLE_INSERT_COL ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_DELETE_ROW ; + HelpID = FN_TABLE_DELETE_ROW ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_DELETE_COL ; + HelpID = FN_TABLE_DELETE_COL ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_SELECT_ALL; + HelpID = FN_TABLE_SELECT_ALL; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_TABLE_SELECT_COL; + HelpID = FN_TABLE_SELECT_COL; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_TABLE_SELECT_ROW; + HelpID = FN_TABLE_SELECT_ROW; + Hide = TRUE; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_TABLE_VERT_NONE; + HelpID = FN_TABLE_VERT_NONE; + RadioCheck = TRUE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_TABLE_VERT_CENTER; + HelpID = FN_TABLE_VERT_CENTER; + RadioCheck = TRUE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_TABLE_VERT_BOTTOM; + HelpID = FN_TABLE_VERT_BOTTOM; + RadioCheck = TRUE; + Hide = TRUE; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_BORDER + }; + ToolBoxItem + { + ITEM_TOOLBAR_FRAME_LINESTYLE + }; + ToolBoxItem + { + ITEM_TOOLBAR_FRAME_LINECOLOR + Hide = TRUE; + }; + ToolBoxItem + { + ITEM_TOOLBAR_BACKGROUND_COLOR + }; + }; +}; +String RID_FRAME_TOOLBOX +{ + Text [ en-US ] = "Frame Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_FRAME_TOOLBOX +{ + HelpID = HID_FRAME_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + MenuStrings = TRUE ; + HideWhenDeactivate = TRUE ; + Customize = TRUE ; + Hide = TRUE ; + ItemList = + { + MN_TEMPLATE + MN_FRAME_WRAP + MN_FRAME1 + MN_FRAME2 + MN_FRAME3 + MN_LINESTYLE + MN_BACKGROUND_COLOR + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + MN_ATTRIBUTES_FRAME + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + MN_LAYER + ToolBoxItem + { + Identifier = FN_TOOL_ANKER ; + HelpID = FN_TOOL_ANKER ; + DropDown = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_FRAME_CHAIN ; + HelpID = FN_FRAME_CHAIN ; + }; + ToolBoxItem + { + Identifier = FN_FRAME_UNCHAIN ; + HelpID = FN_FRAME_UNCHAIN ; + }; + }; + Scroll = TRUE ; +}; +String RID_GRAFIK_TOOLBOX +{ + Text [ en-US ] = "Graphics Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_GRAFIK_TOOLBOX +{ + HelpID = HID_GRAFIK_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + MenuStrings = TRUE ; + Customize = TRUE ; + Hide = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_GRFFILTER; + HelpID = SID_GRFFILTER; + DropDown = TRUE ; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_MODE; + HelpID = SID_ATTR_GRAF_MODE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_RED; + HelpID = SID_ATTR_GRAF_RED; + }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_GREEN; + HelpID = SID_ATTR_GRAF_GREEN; + }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_BLUE; + HelpID = SID_ATTR_GRAF_BLUE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_LUMINANCE; + HelpID = SID_ATTR_GRAF_LUMINANCE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_CONTRAST; + HelpID = SID_ATTR_GRAF_CONTRAST; + }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_GAMMA; + HelpID = SID_ATTR_GRAF_GAMMA; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_TRANSPARENCE; + HelpID = SID_ATTR_GRAF_TRANSPARENCE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = FN_FLIP_VERT_GRAFIC ; + HelpID = FN_FLIP_VERT_GRAFIC ; + }; + ToolBoxItem + { + Identifier = FN_FLIP_HORZ_GRAFIC ; + HelpID = FN_FLIP_HORZ_GRAFIC ; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + MN_ATTRIBUTES_GRAFIK + }; + Scroll = TRUE ; +}; +String RID_OLE_TOOLBOX +{ + Text [ en-US ] = "Object" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_OLE_TOOLBOX +{ + HelpID = HID_OLE_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + Customize = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + Scroll = TRUE ; + ItemList = + { + MN_TEMPLATE + MN_FRAME_WRAP + MN_CONTOUR + MN_FRAME1 + MN_FRAME2 + MN_FRAME3 + MN_LINESTYLE + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + MN_ATTRIBUTES_OLE + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + MN_LAYER + ToolBoxItem + { + Identifier = FN_TOOL_ANKER ; + HelpID = FN_TOOL_ANKER ; + DropDown = TRUE ; + }; + }; +}; +String RID_DRAW_TOOLBOX +{ + Text [ en-US ] = "Draw Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_DRAW_TOOLBOX +{ + HelpID = HID_DRAW_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + Customize = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_BEZIER_EDIT ; + HelpID = SID_BEZIER_EDIT ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_ATTRIBUTES_LINE ; + HelpID = SID_ATTRIBUTES_LINE ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_LINEEND_STYLE + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_LINE_STYLE + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_LINE_WIDTH + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_LINE_COLOR + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_ATTRIBUTES_AREA ; + HelpID = SID_ATTRIBUTES_AREA ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_FILL_STYLE + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_OBJECT_ROTATE + }; + ToolBoxItem + { + Identifier = FN_TOOL_ANKER ; + HelpID = FN_TOOL_ANKER ; + DropDown = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_FRAME_NOWRAP ; + HelpID = FN_FRAME_NOWRAP ; + RadioCheck = TRUE ; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_FRAME_WRAP ; + HelpID = FN_FRAME_WRAP ; + RadioCheck = TRUE ; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_FRAME_WRAP_IDEAL ; + HelpID = FN_FRAME_WRAP_IDEAL ; + RadioCheck = TRUE ; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_FRAME_WRAP_LEFT ; + HelpID = FN_FRAME_WRAP_LEFT ; + RadioCheck = TRUE ; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_FRAME_WRAP_RIGHT ; + HelpID = FN_FRAME_WRAP_RIGHT ; + RadioCheck = TRUE ; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = FN_FRAME_WRAPTHRU ; + HelpID = FN_FRAME_WRAPTHRU ; + RadioCheck = TRUE ; + Hide = TRUE; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_FRAME_WRAP_CONTOUR ; + HelpID = FN_FRAME_WRAP_CONTOUR ; + Hide = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_HEAVEN ; + HelpID = SID_OBJECT_HEAVEN ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_HELL ; + HelpID = SID_OBJECT_HELL ; + }; + MN_LAYER + MN_GRID( HIDE=TRUE ) + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN ; + HelpID = SID_OBJECT_ALIGN ; + DropDown = TRUE ; + }; + }; + Scroll = TRUE ; +}; +String RID_BEZIER_TOOLBOX +{ + Text [ en-US ] = "Bézier Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_BEZIER_TOOLBOX +{ + HelpID = HID_BEZIER_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + Customize = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_BEZIER_EDIT ; + HelpID = SID_BEZIER_EDIT ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_MOVE ; + HelpID = SID_BEZIER_MOVE ; + RadioCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_INSERT ; + HelpID = SID_BEZIER_INSERT ; + RadioCheck = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_DELETE ; + HelpID = SID_BEZIER_DELETE ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_CUTLINE ; + HelpID = SID_BEZIER_CUTLINE ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_CONVERT ; + HelpID = SID_BEZIER_CONVERT ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_EDGE ; + HelpID = SID_BEZIER_EDGE ; + RadioCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_SMOOTH ; + HelpID = SID_BEZIER_SMOOTH ; + RadioCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_SYMMTR ; + HelpID = SID_BEZIER_SYMMTR ; + RadioCheck = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_CLOSE ; + HelpID = SID_BEZIER_CLOSE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_BEZIER_ELIMINATE_POINTS ; + HelpID = SID_BEZIER_ELIMINATE_POINTS ; + }; + }; + Scroll = TRUE ; +}; +String RID_DRAW_TEXT_TOOLBOX +{ + Text [ en-US ] = "Text Object Bar/Graphics" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_DRAW_TEXT_TOOLBOX +{ + HelpID = HID_DRAW_TEXT_TOOLBOX ; + Border = TRUE ; + Customize = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + ItemList = + { + MN_FONT + MN_TEXT1(FALSE) + MN_TEXT1_BLOCK + MN_TEXT_LINESPACE + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_CHAR_COLOR + Hide = TRUE; + }; + MN_TEXT_LTR_RTL + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + }; + + MN_TEXT_DIALOGS(FALSE) + }; + ItemList[ ar ] = + { + MN_FONT + MN_TEXT1_RTL(FALSE) + MN_TEXT1_BLOCK + MN_TEXT_LINESPACE + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_CHAR_COLOR + Hide = TRUE; + }; + MN_TEXT_RTL_LTR + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + }; + + MN_TEXT_DIALOGS(FALSE) + }; + ItemList[ he ] = + { + MN_FONT + MN_TEXT1_RTL(FALSE) + MN_TEXT1_BLOCK + MN_TEXT_LINESPACE + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + ITEM_TOOLBAR_ATTR_CHAR_COLOR + Hide = TRUE; + }; + MN_TEXT_RTL_LTR + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + }; + + MN_TEXT_DIALOGS(FALSE) + }; + Scroll = TRUE ; +}; +String RID_NUM_TOOLBOX +{ + Text [ en-US ] = "Numbering Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_NUM_TOOLBOX +{ + HelpID = HID_NUM_TOOLBOX ; + Border = TRUE ; + SVLook = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + LineSpacing = TRUE ; + HideWhenDeactivate = TRUE ; + Customize = TRUE ; + MenuStrings = TRUE ; + Hide = TRUE ; + ItemList = + { + MN_TEMPLATE + MN_FONT + ToolBoxItem + { + Identifier = FN_NUM_BULLET_OFF ; + HelpID = FN_NUM_BULLET_OFF ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_UP ; + HelpID = FN_NUM_BULLET_UP ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_DOWN ; + HelpID = FN_NUM_BULLET_DOWN ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_OUTLINE_UP ; + HelpID = FN_NUM_BULLET_OUTLINE_UP ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_OUTLINE_DOWN ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_NONUM ; + HelpID = FN_NUM_BULLET_NONUM ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_MOVEUP ; + HelpID = FN_NUM_BULLET_MOVEUP ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_MOVEDOWN ; + HelpID = FN_NUM_BULLET_MOVEDOWN ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_OUTLINE_MOVEUP ; + HelpID = FN_NUM_BULLET_OUTLINE_MOVEUP ; + }; + ToolBoxItem + { + Identifier = FN_NUM_BULLET_OUTLINE_MOVEDOWN ; + HelpID = FN_NUM_BULLET_OUTLINE_MOVEDOWN ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_NUMBER_NEWSTART ; + HelpID = FN_NUMBER_NEWSTART ; + }; + ToolBoxItem + { + Identifier = FN_NUMBER_BULLETS ; + HelpID = FN_NUMBER_BULLETS ; + }; + }; + Scroll = TRUE ; +}; +String STR_SHELLNAME_TEXT +{ + Text [ en-US ] = "Text" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_TABLE +{ + Text [ en-US ] = "Table" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_FRAME +{ + Text [ en-US ] = "Frame" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_GRAPHIC +{ + Text [ en-US ] = "Graphics" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_OBJECT +{ + Text [ en-US ] = "Object" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_LIST +{ + Text [ en-US ] = "List" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_DRAW +{ + Text [ en-US ] = "Drawing" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_DRAWFORM +{ + Text [ en-US ] = "Forms" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_BEZIER +{ + Text [ en-US ] = "Bézier" ; + Text [ x-comment ] = " "; +}; +String STR_SHELLNAME_DRAW_TEXT +{ + Text [ en-US ] = "Draw text" ; + Text [ x-comment ] = " "; +}; + //Strings fuer Gallery/Hintergrund +String STR_SWBG_PARAGRAPH +{ + Text [ en-US ] = "Paragraph" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_GRAPHIC +{ + Text [ en-US ] = "Graphics" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_OLE +{ + Text [ en-US ] = "OLE object" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_FRAME +{ + Text [ en-US ] = "Frame" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_TABLE +{ + Text [ en-US ] = "Table" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_TABLE_ROW +{ + Text [ en-US ] = "Table row" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_TABLE_CELL +{ + Text [ en-US ] = "Table cell" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_PAGE +{ + Text [ en-US ] = "Page" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_HEADER +{ + Text [ en-US ] = "Header" ; + Text [ x-comment ] = " "; +}; +String STR_SWBG_FOOTER +{ + Text [ en-US ] = "Footer" ; + Text [ x-comment ] = " "; +}; + //Ende: Strings fuer Gallery/Hintergrund + +// #i68101# no longer needed: +// String STR_NAME_SHAPE_LABEL {// String STR_NAME_SHAPE_DIALOG { Text [ de ] = "Objekt benennen" ; Text [ en-US ] = "Name Object"; }; + + diff --git a/sw/source/ui/shells/slotadd.cxx b/sw/source/ui/shells/slotadd.cxx new file mode 100644 index 000000000000..9d162f57aa6f --- /dev/null +++ b/sw/source/ui/shells/slotadd.cxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 "hintids.hxx" +#include "uiitems.hxx" +#include "cmdid.h" + +#include <svl/globalnameitem.hxx> +#include <editeng/memberids.hrc> +#include <svl/imageitm.hxx> +#include <svl/aeitem.hxx> +#include <svl/rectitem.hxx> +#include <sfx2/objitem.hxx> +#include <sfx2/objsh.hxx> +#include <svx/rulritem.hxx> +#include <svx/zoomitem.hxx> +#include <svx/viewlayoutitem.hxx> +#include <svx/zoomslideritem.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/SmartTagItem.hxx> +#include <svl/ptitem.hxx> +#include <svx/pageitem.hxx> +#include <svl/srchitem.hxx> +#include <sfx2/tplpitem.hxx> +#include <editeng/wrlmitem.hxx> +#include <editeng/protitem.hxx> +#include <editeng/opaqitem.hxx> +#ifndef _SVX_TSTPITEM_HXX //autogen +#include <editeng/tstpitem.hxx> +#endif +#include <editeng/akrnitem.hxx> +#include <editeng/keepitem.hxx> +#include <editeng/kernitem.hxx> +#include <editeng/spltitem.hxx> +#include <editeng/brshitem.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/shaditem.hxx> +#include <editeng/pbinitem.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/prntitem.hxx> +#include <editeng/orphitem.hxx> +#include <editeng/widwitem.hxx> +#include <editeng/bolnitem.hxx> +#include <editeng/pmdlitem.hxx> +#include <editeng/cmapitem.hxx> +#include <editeng/langitem.hxx> +#include <editeng/brkitem.hxx> +#include <editeng/hyznitem.hxx> +#include <editeng/escpitem.hxx> +#include <editeng/lspcitem.hxx> +#include <editeng/adjitem.hxx> +#include <editeng/crsditem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/shdditem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/postitem.hxx> +#include <editeng/fhgtitem.hxx> +#ifndef _SVX_CNTRITEM_HXX //autogen +#include <editeng/cntritem.hxx> +#endif +#include <editeng/colritem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/sizeitem.hxx> +#include <editeng/lrspitem.hxx> +#include <svx/xgrad.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xflclit.hxx> +#include <svx/xflgrit.hxx> +#include <svx/xflhtit.hxx> +#include <svx/xbtmpit.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlnwtit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xtextit0.hxx> +#include <svx/xftadit.hxx> +#include <svx/xftdiit.hxx> +#include <svx/xftstit.hxx> +#include <svx/xftmrit.hxx> +#include <svx/xftouit.hxx> +#include <svx/xftshit.hxx> +#include <svx/xftshcit.hxx> +#include <svx/xftshxy.hxx> +#include <svx/xftsfit.hxx> +#include <svx/grafctrl.hxx> + + +#include <fmtornt.hxx> +#include <paratr.hxx> +#include <fmtinfmt.hxx> +#include <fmtfsize.hxx> +#include <fmtsrnd.hxx> +#include "envimg.hxx" +#include "frmatr.hxx" +#include "cfgitems.hxx" +#include "grfatr.hxx" +#include "fmtline.hxx" +#include <svx/clipfmtitem.hxx> +#include <editeng/blnkitem.hxx> +#include <svl/slstitm.hxx> +#include <editeng/paravertalignitem.hxx> +#include <editeng/charreliefitem.hxx> +#include <editeng/charrotateitem.hxx> +#include <editeng/charscaleitem.hxx> +#include <svx/postattr.hxx> +#include <sfx2/frame.hxx> +#include <svx/chrtitem.hxx> +#include <svx/drawitem.hxx> +#include <avmedia/mediaitem.hxx> + +#define SvxDrawToolItem SfxAllEnumItem +#define SvxDrawAlignItem SfxAllEnumItem +#define SvxDrawBezierItem SfxAllEnumItem +#define avmedia_MediaItem ::avmedia::MediaItem + +#define SFX_TYPEMAP +#include <sfx2/msg.hxx> +#include "swslots.hxx" + + + diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx new file mode 100644 index 000000000000..5f3389791122 --- /dev/null +++ b/sw/source/ui/shells/tabsh.cxx @@ -0,0 +1,1597 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> + +#ifndef _ZFORLIST_HXX +#define _ZFORLIST_DECLARE_TABLE +#include <svl/zforlist.hxx> +#endif +#include <svl/stritem.hxx> +#include <svl/whiter.hxx> +#include <unotools/moduleoptions.hxx> +#include <svx/rulritem.hxx> +#include <svl/srchitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/brshitem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/shaditem.hxx> +#include <editeng/spltitem.hxx> +#include <editeng/langitem.hxx> +#include <editeng/keepitem.hxx> +#include <editeng/bolnitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/frmdiritem.hxx> +#include <svx/numinf.hxx> +#include <svx/svddef.hxx> +#include <svx/svxdlg.hxx> +#include <svl/zformat.hxx> +#include <sfx2/bindings.hxx> +#include <vcl/msgbox.hxx> +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objface.hxx> + + +#include <fmtornt.hxx> +#include <fmtclds.hxx> +#include <fmtlsplt.hxx> +#include <fmtrowsplt.hxx> +#include <fmtfsize.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <wview.hxx> +#include <frmatr.hxx> +#include <uitool.hxx> +#include <inputwin.hxx> +#include <uiitems.hxx> +#include <usrpref.hxx> +#include <tabsh.hxx> +#include "swtablerep.hxx" +#include <tablemgr.hxx> +#include <cellatr.hxx> +#include <frmfmt.hxx> +#include <swundo.hxx> +#include <swtable.hxx> +#include <docsh.hxx> +#include <tblsel.hxx> + +#include <dialog.hrc> + + + +//!!! new: insert table +/* +#include <svx/htmlmode.hxx> +#include <modcfg.hxx> +#include <tblafmt.hxx> +#include <instable.hxx> +*/ +//!!! + +#ifndef _POPUP_HRC +#include <popup.hrc> +#endif +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif +#ifndef _TABLE_HRC +#include <table.hrc> +#endif +#include <cmdid.h> +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif +#include <helpid.h> +#include <unobaseclass.hxx> + +#define SwTableShell +#include <sfx2/msg.hxx> +#include <swslots.hxx> + +#include "swabstdlg.hxx" +#include <table.hrc> + +using namespace ::com::sun::star; + +//----------------------------------------------------------------------------- + +SFX_IMPL_INTERFACE(SwTableShell, SwBaseShell, SW_RES(STR_SHELLNAME_TABLE)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TABLE_TOOLBOX)); +} + + +TYPEINIT1(SwTableShell,SwBaseShell) + +/************************************************************************/ + +const USHORT __FAR_DATA aUITableAttrRange[] = +{ + FN_PARAM_TABLE_NAME, FN_PARAM_TABLE_NAME, + FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE, + FN_PARAM_TABLE_SPACE, FN_PARAM_TABLE_SPACE, + FN_TABLE_REP, FN_TABLE_REP, + SID_RULER_BORDERS, SID_RULER_BORDERS, + RES_LR_SPACE, RES_UL_SPACE, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW, + RES_BOX, RES_SHADOW, + RES_BACKGROUND, RES_BACKGROUND, + SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION, + SID_HTML_MODE, SID_HTML_MODE, + SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE, + RES_PAGEDESC, RES_BREAK, + RES_KEEP, RES_KEEP, + RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, + FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN, + RES_FRAMEDIR, RES_FRAMEDIR, + RES_ROW_SPLIT, RES_ROW_SPLIT, + FN_TABLE_BOX_TEXTDIRECTION, FN_TABLE_BOX_TEXTDIRECTION, +// --> collapsing borders FME 2005-05-27 #i29550# + RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS, +// <-- collapsing borders + 0 +}; + +const USHORT* SwuiGetUITableAttrRange() +{ + return aUITableAttrRange; +} + +static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem ) +{ + SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which(), 0); + aSet.Put( rItem ); + rSh.SetTblAttr( aSet ); +} + +/************************************************************************/ + + +static SwTableRep* lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh ) +{ + SwFrmFmt *pFmt = rSh.GetTableFmt(); + SwTabCols aCols; + rSh.GetTabCols( aCols ); + + //Ersteinmal die einfachen Attribute besorgen. + rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFmt->GetName())); + rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) ); + rSet.Put( pFmt->GetShadow() ); + rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign())); + rSet.Put( pFmt->GetFrmDir() ); + + SvxULSpaceItem aULSpace( pFmt->GetULSpace() ); + rSet.Put( aULSpace ); + + USHORT nBackgroundDestination = rSh.GetViewOptions()->GetTblDest(); + rSet.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION, nBackgroundDestination )); + SvxBrushItem aBrush( RES_BACKGROUND ); +// rSh.GetBoxBackground(aBrush); +// rSet.Put( aBrush ); + if(rSh.GetRowBackground(aBrush)) + rSet.Put( aBrush, SID_ATTR_BRUSH_ROW ); + else + rSet.InvalidateItem(SID_ATTR_BRUSH_ROW); + rSh.GetTabBackground(aBrush); + rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE ); + + // text direction in boxes + SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR ); + if(rSh.GetBoxDirection( aBoxDirection )) + rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION); + + BOOL bTableSel = rSh.IsTableMode(); + if(!bTableSel) + { + rSh.StartAllAction(); + rSh.Push(); + rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL, FALSE ); + } + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + + // Tabellenvariante, wenn mehrere Tabellenzellen selektiert + rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert + aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1 || + !bTableSel); + // Abstandsfeld immer anzeigen + aBoxInfo.SetDist ((BOOL) TRUE); + // Minimalgroesse in Tabellen und Absaetzen setzen + aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() || + rSh.GetSelectionType() & + (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL)); + // Default-Abstand immer setzen + aBoxInfo.SetDefDist (MIN_BORDER_DIST); + // Einzelne Linien koennen nur in Tabellen DontCare-Status haben + aBoxInfo.SetValid( VALID_DISABLE, !bTableSel || !rSh.IsTableMode() ); + + rSet.Put(aBoxInfo); + rSh.GetTabBorders( rSet ); + + //row split + SwFmtRowSplit* pSplit = 0; + rSh.GetRowSplit(pSplit); + if(pSplit) + { + rSet.Put(*pSplit); + delete pSplit; + } + + if(!bTableSel) + { + rSh.ClearMark(); + rSh.Pop(FALSE); + rSh.EndAllAction(); + } + + SwTabCols aTabCols; + rSh.GetTabCols( aTabCols ); + SvxColumnItem aColItem; + + + // Pointer wird nach der Dialogausfuehrung geloescht + SwTableRep* pRep = new SwTableRep( aTabCols, rSh.IsTblComplex()); + pRep->SetSpace(aCols.GetRightMax()); + + USHORT nPercent = 0; + long nWidth = ::GetTableWidth(pFmt, aCols, &nPercent, &rSh ); + // Die Tabellenbreite ist fuer relative Angaben nicht korrekt + if(nPercent) + nWidth = pRep->GetSpace() * nPercent / 100; + USHORT nAlign = pFmt->GetHoriOrient().GetHoriOrient(); + pRep->SetAlign(nAlign); + SvxLRSpaceItem aLRSpace( pFmt->GetLRSpace() ); + SwTwips nLeft = aLRSpace.GetLeft(); + SwTwips nRight = aLRSpace.GetRight(); + SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth; + if(nAlign != text::HoriOrientation::FULL && Abs(nDiff) > 2) + { + SwTwips nLR = pRep->GetSpace() - nWidth; + switch ( nAlign ) + { + case text::HoriOrientation::CENTER: nLeft = nRight = nLR / 2; + break; + case text::HoriOrientation::LEFT: nRight = nLR; nLeft = 0; + break; + case text::HoriOrientation::RIGHT: nLeft = nLR, nRight = 0; + break; + case text::HoriOrientation::LEFT_AND_WIDTH: + nRight = nLR - nLeft; + break; + case text::HoriOrientation::NONE: + if(!nPercent) + nWidth = pRep->GetSpace() - nLeft - nRight; + break; + } + } + pRep->SetLeftSpace(nLeft); + pRep->SetRightSpace(nRight); + + pRep->SetWidth(nWidth); + pRep->SetWidthPercent(nPercent); + // sind einzelne Zeilen/Zellen selektiert, wird die Spaltenbearbeitung veraendert + pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection()); + rSet.Put(SwPtrItem(FN_TABLE_REP, pRep)); + return pRep; +} + +/************************************************************************/ + + +void ItemSetToTableParam( const SfxItemSet& rSet, + SwWrtShell &rSh ) +{ + rSh.StartAllAction(); + rSh.StartUndo( UNDO_TABLE_ATTR ); + const SfxPoolItem* pItem = 0; + + SwViewOption aUsrPref( *rSh.GetViewOptions() ); + USHORT nBackgroundDestination = aUsrPref.GetTblDest(); + if(SFX_ITEM_SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, FALSE, &pItem)) + { + nBackgroundDestination = ((SfxUInt16Item*)pItem)->GetValue(); + aUsrPref.SetTblDest((BYTE)nBackgroundDestination); + SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView()); + } + BOOL bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) || + SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) ); + pItem = 0; + BOOL bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, FALSE, &pItem ); + const SfxPoolItem* pRowItem = 0, *pTableItem = 0; + bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, FALSE, &pRowItem ); + bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, FALSE, &pTableItem ); + const SfxPoolItem* pSplit = 0; + BOOL bRowSplit = SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, FALSE, &pSplit ); + const SfxPoolItem* pBoxDirection = 0; + BOOL bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, FALSE, &pBoxDirection ); + if( bBackground || bBorder || bRowSplit || bBoxDirection) + { + /* + Die Umrandung wird auf die vorliegende Selektion angewendet + Liegt keine Selektion vor, wird die Tabelle vollstaendig selektiert. + Der Hintergrund wird immer auf den aktuellen Zustand angewendet. + */ + + BOOL bTableSel = rSh.IsTableMode(); + rSh.StartAllAction(); + + if(bBackground) + { + if(pItem) + rSh.SetBoxBackground( *(const SvxBrushItem*)pItem ); + if(pRowItem) + { + SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem); + aBrush.SetWhich(RES_BACKGROUND); + rSh.SetRowBackground(aBrush); + } + if(pTableItem) + { + SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem); + aBrush.SetWhich(RES_BACKGROUND); + rSh.SetTabBackground( aBrush ); + } + } + + if(bBoxDirection) + { + SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR ); + aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue()); + rSh.SetBoxDirection(aDirection); + } + + if(bBorder || bRowSplit) + { + rSh.Push(); + if(!bTableSel) + { + rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL ); + } + if(bBorder) + rSh.SetTabBorders( rSet ); + + if(bRowSplit) + { + rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pSplit)); + } + + if(!bTableSel) + { + rSh.ClearMark(); + } + rSh.Pop(FALSE); + } + + rSh.EndAllAction(); + } + + SwTabCols aTabCols; + BOOL bTabCols = FALSE; + BOOL bSingleLine = FALSE; + SwTableRep* pRep = 0; + SwFrmFmt *pFmt = rSh.GetTableFmt(); + SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); + if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, FALSE, &pItem )) + { + pRep = (SwTableRep*)((const SwPtrItem*)pItem)->GetValue(); + + const SwTwips nWidth = pRep->GetWidth(); + if ( text::HoriOrientation::FULL == pRep->GetAlign() ) + { + SwFmtHoriOrient aAttr( pFmt->GetHoriOrient() ); + aAttr.SetHoriOrient( text::HoriOrientation::FULL ); + aSet.Put( aAttr ); + } + else + { + SwFmtFrmSize aSz( ATT_VAR_SIZE, nWidth ); + if(pRep->GetWidthPercent()) + { + aSz.SetWidthPercent( (BYTE)pRep->GetWidthPercent() ); + } + aSet.Put(aSz); + } + + SvxLRSpaceItem aLRSpace( RES_LR_SPACE ); + aLRSpace.SetLeft(pRep->GetLeftSpace()); + aLRSpace.SetRight(pRep->GetRightSpace()); + aSet.Put( aLRSpace ); + + sal_Int16 eOrient = pRep->GetAlign(); + SwFmtHoriOrient aAttr( 0, eOrient ); + aSet.Put( aAttr ); + // Damit beim recording die Ausrichtung nicht durch die Abstaende ueberschrieben + // wird, darf das Item nur bei manueller Ausrichtung aufgez. werden + if(eOrient != text::HoriOrientation::NONE) + ((SfxItemSet&)rSet).ClearItem( SID_ATTR_LRSPACE ); + + + if(pRep->HasColsChanged()) + { + bTabCols = TRUE; + } + } + + + if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, FALSE, &pItem)) + rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() ); + + if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, FALSE, &pItem)) + rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue()); + + if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, FALSE, &pItem )) + rSh.SetTableName( *pFmt, ((const SfxStringItem*)pItem)->GetValue() ); + + // kopiere die ausgesuchten Attribute in den ItemSet + static USHORT __READONLY_DATA aIds[] = + { + RES_PAGEDESC, + RES_BREAK, + RES_KEEP, + RES_LAYOUT_SPLIT, + RES_UL_SPACE, + RES_SHADOW, + RES_FRAMEDIR, + // --> collapsing borders FME 2005-05-27 #i29550# + RES_COLLAPSING_BORDERS, + // <-- collapsing borders + 0 + }; + for( const USHORT* pIds = aIds; *pIds; ++pIds ) + if( SFX_ITEM_SET == rSet.GetItemState( *pIds, FALSE, &pItem)) + aSet.Put( *pItem ); + + if( aSet.Count() ) + rSh.SetTblAttr( aSet ); + + if(bTabCols) + { + rSh.GetTabCols( aTabCols ); + bSingleLine = pRep->FillTabCols( aTabCols ); + rSh.SetTabCols( aTabCols, bSingleLine ); + } + + rSh.EndUndo( UNDO_TABLE_ATTR ); + rSh.EndAllAction(); +} + +/************************************************************************/ + + +static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine) +{ + if(pBorderLine->GetInWidth() > rBorderLine.GetInWidth()) + rBorderLine.SetInWidth(pBorderLine->GetInWidth()); + + if(pBorderLine->GetOutWidth() > rBorderLine.GetOutWidth()) + rBorderLine.SetOutWidth(pBorderLine->GetOutWidth()); + + if(pBorderLine->GetDistance() > rBorderLine.GetDistance()) + rBorderLine.SetDistance(pBorderLine->GetDistance()); + + rBorderLine.SetColor(pBorderLine->GetColor()); +} + + +void SwTableShell::Execute(SfxRequest &rReq) +{ + BOOL bUseDialog = TRUE; + const SfxItemSet* pArgs = rReq.GetArgs(); + SwWrtShell &rSh = GetShell(); + + //Erstmal die Slots, die keinen FrmMgr benoetigen. + BOOL bMore = FALSE; + const SfxPoolItem* pItem = 0; + USHORT nSlot = rReq.GetSlot(); + if(pArgs) + pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem); + BOOL bCallDone = FALSE; + switch ( nSlot ) + { + case SID_ATTR_BORDER: + { +/* BOOL bPopCrsr = FALSE; + if ( !rReq.IsAPI() ) + { + //Keine Tabellenselektion -> Aenderung wird auf die gesamte + //Tabelle. + if ( !rSh.IsTableMode() ) + { + rSh.StartAction(); + bPopCrsr = TRUE; + rSh.Push(); + rSh.EnterStdMode(); + rSh.MoveTable( fnTableCurr, fnTableStart ); + rSh.SttSelect(); + rSh.MoveTable( fnTableCurr, fnTableEnd ); + rSh.EndSelect(); + } + }*/ + if(!pArgs) + break; + //Items erzeugen, weil wir sowieso nacharbeiten muessen + SvxBoxItem aBox( RES_BOX ); + SfxItemSet aCoreSet( GetPool(), + RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + 0); + SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER ); + aCoreSet.Put(aCoreInfo); + rSh.GetTabBorders( aCoreSet ); + const SvxBoxItem& rCoreBox = (const SvxBoxItem&) + aCoreSet.Get(RES_BOX); + const SfxPoolItem *pBoxItem = 0; + if ( pArgs->GetItemState(RES_BOX, TRUE, &pBoxItem) == SFX_ITEM_SET ) + { + aBox = *(SvxBoxItem*)pBoxItem; + if ( !rReq.IsAPI() ) + aBox.SetDistance( Max(rCoreBox.GetDistance(),USHORT(55)) ); + else if ( aBox.GetDistance() < MIN_BORDER_DIST ) + aBox.SetDistance( Max(rCoreBox.GetDistance(),(USHORT)MIN_BORDER_DIST) ); + } + else + {ASSERT( !this, "Wo ist das Box-Item?" )} + + //since the drawing layer also supports borders the which id might be a different one + SvxBoxInfoItem aInfo( SID_ATTR_BORDER_INNER ); + if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, TRUE, &pBoxItem) == SFX_ITEM_SET) + aInfo = *(SvxBoxInfoItem*)pBoxItem; + else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, TRUE, &pBoxItem) == SFX_ITEM_SET ) + { + aInfo = *(SvxBoxInfoItem*)pBoxItem; + aInfo.SetWhich(SID_ATTR_BORDER_INNER); + } + + aInfo.SetTable( TRUE ); + aInfo.SetValid( VALID_DISABLE, FALSE ); + + +// Die Attribute aller Linien werden gelesen und das staerkste gewinnt + const SvxBorderLine* pBorderLine; + SvxBorderLine aBorderLine; + if ((pBorderLine = rCoreBox.GetTop()) != NULL) + lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = rCoreBox.GetBottom()) != NULL) + lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = rCoreBox.GetLeft()) != NULL) + lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = rCoreBox.GetRight()) != NULL) + lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = aCoreInfo.GetHori()) != NULL) + lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine); + if ((pBorderLine = aCoreInfo.GetVert()) != NULL) + lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine); + + if(aBorderLine.GetOutWidth() == 0) + { + aBorderLine.SetInWidth(0); + aBorderLine.SetOutWidth(DEF_LINE_WIDTH_0); + } + + BOOL bLine = FALSE; + if ( (pBorderLine = aBox.GetTop()) != NULL) + aBox.SetLine(&aBorderLine, BOX_LINE_TOP), bLine |= TRUE; + if ((pBorderLine = aBox.GetBottom()) != NULL) + aBox.SetLine(&aBorderLine, BOX_LINE_BOTTOM), bLine |= TRUE; + if ((pBorderLine = aBox.GetLeft()) != NULL) + aBox.SetLine(&aBorderLine, BOX_LINE_LEFT), bLine |= TRUE; + if ((pBorderLine = aBox.GetRight()) != NULL) + aBox.SetLine(&aBorderLine, BOX_LINE_RIGHT), bLine |= TRUE; + if ((pBorderLine = aInfo.GetHori()) != NULL) + aInfo.SetLine(&aBorderLine, BOXINFO_LINE_HORI), bLine |= TRUE; + if ((pBorderLine = aInfo.GetVert()) != NULL) + aInfo.SetLine(&aBorderLine, BOXINFO_LINE_VERT), bLine |= TRUE; + +// if ( bPopCrsr && !bLine ) +// aBox.SetDistance( 0 ); + + aCoreSet.Put( aBox ); + aCoreSet.Put( aInfo ); + rSh.SetTabBorders( aCoreSet ); + + // we must record the "real" values because otherwise the lines can't be reconstructed on playtime + // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in + // the SvxBoxItem + rReq.AppendItem( aBox ); + rReq.AppendItem( aInfo ); + bCallDone = TRUE; + +/* if ( bPopCrsr ) + { + rSh.KillPams(); + rSh.Pop(FALSE); + rSh.EndAction(); + }*/ + } + break; + case FN_INSERT_TABLE: + InsertTable( rReq ); + break; + case FN_FORMAT_TABLE_DLG: + { + //#127012# get the bindings before the dialog is called + // it might happen that this shell is removed after closing the dialog + SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings(); + SfxItemSet aCoreSet( GetPool(), aUITableAttrRange); + + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric))); + SwTableRep* pTblRep = ::lcl_TableParamToItemSet( aCoreSet, rSh ); + SfxAbstractTabDialog * pDlg = NULL; + if ( bUseDialog ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + pDlg = pFact->CreateSwTableTabDlg( GetView().GetWindow(), GetPool(), &aCoreSet, &rSh, DLG_FORMAT_TABLE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + } + aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell()))); + rSh.GetTblAttr(aCoreSet); + // GetTblAttr buegelt den Background ueber! + SvxBrushItem aBrush( RES_BACKGROUND ); + if(rSh.GetBoxBackground(aBrush)) + aCoreSet.Put( aBrush ); + else + aCoreSet.InvalidateItem( RES_BACKGROUND ); + + if ( !pDlg && rReq.GetArgs() || pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg ? pDlg->GetOutputItemSet() : rReq.GetArgs(); + if ( pDlg ) + { + //to record FN_INSERT_TABLE correctly + rReq.SetSlot(FN_FORMAT_TABLE_DLG); + rReq.Done( *pOutSet ); + } + ItemSetToTableParam( *pOutSet, rSh ); + } + + delete pDlg; + delete pTblRep; + rBindings.Update(SID_RULER_BORDERS); + rBindings.Update(SID_ATTR_TABSTOP); + rBindings.Update(SID_RULER_BORDERS_VERTICAL); + rBindings.Update(SID_ATTR_TABSTOP_VERTICAL); + } + break; + case SID_ATTR_BRUSH: + case SID_ATTR_BRUSH_ROW : + case SID_ATTR_BRUSH_TABLE : + if(rReq.GetArgs()) + ItemSetToTableParam(*rReq.GetArgs(), rSh); + break; + case FN_NUM_FORMAT_TABLE_DLG: + { + SwView* pView = GetActiveView(); + if(pView) + { + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric))); + SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); + SfxItemSet aCoreSet( GetPool(), + SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, + SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO, + 0 ); + + SfxItemSet aBoxSet( *aCoreSet.GetPool(), + RES_BOXATR_FORMAT, RES_BOXATR_FORMAT, + RES_BOXATR_VALUE, RES_BOXATR_VALUE, + 0 ); + rSh.GetTblBoxFormulaAttrs( aBoxSet ); + + SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT); + if(eState == SFX_ITEM_DEFAULT) + { + aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, + pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM))); + } + else + aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, + ((SwTblBoxNumFormat&)aBoxSet.Get( + RES_BOXATR_FORMAT )).GetValue() )); + + String sCurText( rSh.GetTableBoxText() ); + aCoreSet.Put( SvxNumberInfoItem( pFormatter, + ((SwTblBoxValue&)aBoxSet.Get( + RES_BOXATR_VALUE)).GetValue(), + sCurText, SID_ATTR_NUMBERFORMAT_INFO )); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(),aCoreSet, + pView->GetViewFrame()->GetFrame().GetFrameInterface(), + RC_DLG_SWNUMFMTDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + + if (RET_OK == pDlg->Execute()) + { + const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()-> + GetItem( SID_ATTR_NUMBERFORMAT_INFO ); + + if( pNumberFormatItem && 0 != ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount() ) + { + const sal_uInt32* pDelArr = ((SvxNumberInfoItem*) + pNumberFormatItem)->GetDelArray(); + + for ( USHORT i = 0; i < ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount(); i++ ) + ((SvxNumberInfoItem*)pNumberFormatItem)-> + GetNumberFormatter()->DeleteEntry( pDelArr[i] ); + } + + if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState( + SID_ATTR_NUMBERFORMAT_VALUE, FALSE, &pNumberFormatItem )) + { + SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(), + RES_BOXATR_FORMAT, RES_BOXATR_FORMAT ); + aBoxFormatSet.Put( SwTblBoxNumFormat( + ((SfxUInt32Item*)pNumberFormatItem)->GetValue() )); + rSh.SetTblBoxFormulaAttrs( aBoxFormatSet ); + + } + } + delete pDlg; + } + } + break; + case FN_CALC_TABLE: + rSh.UpdateTable(); + bCallDone = TRUE; + break; + case FN_TABLE_OPTIMAL_HEIGHT: + { + const SwFmtFrmSize aSz; + rSh.SetRowHeight( aSz ); + bCallDone = TRUE; + } + break; + case FN_TABLE_DELETE_COL: + if ( rSh.DeleteCol() && rSh.HasSelection() ) + rSh.EnterStdMode(); + bCallDone = TRUE; + break; + case FN_END_TABLE: + rSh.MoveTable( fnTableCurr, fnTableEnd ); + bCallDone = TRUE; + break; + case FN_START_TABLE: + rSh.MoveTable( fnTableCurr, fnTableStart ); + bCallDone = TRUE; + break; + case FN_GOTO_NEXT_CELL: + { + BOOL bAppendLine = TRUE; + if( pItem ) + bAppendLine = ((SfxBoolItem*)pItem)->GetValue(); + rReq.SetReturnValue( SfxBoolItem( nSlot, + rSh.GoNextCell( bAppendLine ) ) ); + bCallDone = TRUE; + } + break; + case FN_GOTO_PREV_CELL: + rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) ); + bCallDone = TRUE; + break; + case FN_TABLE_DELETE_ROW: + if ( rSh.DeleteRow() && rSh.HasSelection() ) + rSh.EnterStdMode(); + bCallDone = TRUE; + break; + case FN_TABLE_MERGE_CELLS: + if ( rSh.IsTableMode() ) + switch ( rSh.MergeTab() ) + { + case TBLMERGE_OK: + bCallDone = TRUE; + //no break; + case TBLMERGE_NOSELECTION: break; + case TBLMERGE_TOOCOMPLEX: + { + InfoBox aInfoBox( GetView().GetWindow(), + SW_RES( MSG_ERR_TABLE_MERGE ) ); + aInfoBox.Execute(); + break; + } + default: ASSERT( !this, "unbekannter Returnwert MergeTab."); + } + break; + case FN_TABLE_ADJUST_CELLS: + case FN_TABLE_BALANCE_CELLS: + { + BOOL bBalance = (FN_TABLE_BALANCE_CELLS == nSlot); + if ( rSh.IsAdjustCellWidthAllowed(bBalance) ) + { + { + // remove actions to make a valid table selection + UnoActionRemoveContext aRemoveContext(rSh.GetDoc()); + } + rSh.AdjustCellWidth(bBalance); + } + bCallDone = TRUE; + } + break; + case FN_TABLE_BALANCE_ROWS: + if ( rSh.BalanceRowHeight(TRUE) ) + rSh.BalanceRowHeight(FALSE); + bCallDone = TRUE; + break; + case FN_TABLE_SELECT_ALL: + rSh.EnterStdMode(); + rSh.MoveTable( fnTableCurr, fnTableStart ); + rSh.SttSelect(); + rSh.MoveTable( fnTableCurr, fnTableEnd ); + rSh.EndSelect(); + bCallDone = TRUE; + break; + case FN_TABLE_SELECT_COL: + rSh.EnterStdMode(); + rSh.SelectTableCol(); + bCallDone = TRUE; + break; + case FN_TABLE_SELECT_ROW: + rSh.EnterStdMode(); + rSh.SelectTableRow(); + bCallDone = TRUE; + break; + case FN_TABLE_SET_READ_ONLY_CELLS: + rSh.ProtectCells(); + rSh.ResetSelect( 0, FALSE ); + bCallDone = TRUE; + break; + case FN_TABLE_UNSET_READ_ONLY_CELLS: + rSh.UnProtectCells(); + bCallDone = TRUE; + break; + case SID_AUTOFORMAT: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(&GetView().GetViewFrame()->GetWindow(), &rSh , DLG_AUTOFMT_TABLE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + break; + case FN_TABLE_SET_ROW_HEIGHT: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_ROW_HEIGHT ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + break; + case FN_NUMBER_BULLETS: + case FN_NUM_BULLET_ON: + ASSERT( !this, "Funktion darf zur Zeit nicht gerufen werden." ); + break; + + case FN_TABLE_INSERT_COL: + case FN_TABLE_INSERT_ROW: + { + BOOL bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL; + USHORT nCount = 0; + BOOL bAfter = TRUE; + if (pItem) + { + nCount = ((const SfxInt16Item* )pItem)->GetValue(); + if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, TRUE, &pItem)) + bAfter = ((const SfxBoolItem* )pItem)->GetValue(); + } + else if( !rReq.IsAPI() ) + ++nCount; + + if( nCount ) + { + // i74180: Table border patch submitted by chensuchun: + // -->get the SvxBoxInfoItem of the table before insert + SfxItemSet aCoreSet( GetPool(), aUITableAttrRange); + ::lcl_TableParamToItemSet( aCoreSet, rSh ); + bool bSetInnerBorders = false; + SwUndoId nUndoId = UNDO_EMPTY; + // <--End + + if( bColumn ) + { + rSh.StartUndo( UNDO_TABLE_INSCOL ); + rSh.InsertCol( nCount, bAfter ); + bSetInnerBorders = true; + nUndoId = UNDO_TABLE_INSCOL; + } + else if ( !rSh.IsInRepeatedHeadline() ) + { + rSh.StartUndo( UNDO_TABLE_INSROW ); + rSh.InsertRow( nCount, bAfter ); + bSetInnerBorders = true; + nUndoId = UNDO_TABLE_INSROW; + } + + // -->after inserting,reset the inner table borders + if ( bSetInnerBorders ) + { + const SvxBoxInfoItem aBoxInfo((const SvxBoxInfoItem&) + aCoreSet.Get(SID_ATTR_BORDER_INNER)); + SfxItemSet aSet( GetPool(), SID_ATTR_BORDER_INNER, + SID_ATTR_BORDER_INNER, 0); + aSet.Put( aBoxInfo ); + ItemSetToTableParam( aSet, rSh ); + rSh.EndUndo( nUndoId ); + } + // <-- + + bCallDone = TRUE; + break; + } + + nSlot = bColumn ? FN_TABLE_INSERT_COL_DLG : FN_TABLE_INSERT_ROW_DLG; + } + // kein break; bei Count = 0 kommt der Dialog + case FN_TABLE_INSERT_COL_DLG: + case FN_TABLE_INSERT_ROW_DLG: + { + if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline()) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot == FN_TABLE_INSERT_COL_DLG, nSlot) : 0); + + if( pDlg.get() && (pDlg->Execute() == 1) ) + { + USHORT nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG) ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW; + SfxUInt16Item aCountItem( nDispatchSlot, static_cast< UINT16 >(pDlg->getInsertCount()) ); + SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if( pVFrame ) + pVFrame->GetDispatcher()->Execute( nDispatchSlot, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aCountItem, &aAfter, 0L); + } + } + } + break; + case FN_TABLE_SPLIT_CELLS: + { + long nCount=0; + BOOL bHorizontal=TRUE; + BOOL bProportional = FALSE; + SFX_REQUEST_ARG( rReq, pSplit, SfxInt32Item, FN_TABLE_SPLIT_CELLS, sal_False ); + SFX_REQUEST_ARG( rReq, pHor, SfxBoolItem, FN_PARAM_1, sal_False ); + SFX_REQUEST_ARG( rReq, pProp, SfxBoolItem, FN_PARAM_2, sal_False ); + if ( pSplit ) + { + nCount = pSplit->GetValue(); + if ( pHor ) + bHorizontal = pHor->GetValue(); + if ( pProp ) + bProportional = pProp->GetValue(); + } + else + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if( pFact ) + { + const long nMaxVert = rSh.GetAnyCurRect( RECT_FRM ).Width() / MINLAY; + SvxAbstractSplittTableDialog* pDlg = pFact->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh.IsTableVertical(), nMaxVert, 99 ); + if( pDlg && (pDlg->Execute() == RET_OK) ) + { + nCount = pDlg->GetCount(); + bHorizontal = pDlg->IsHorizontal(); + bProportional = pDlg->IsProportional(); + rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) ); + } + delete pDlg; + } + } + + if ( nCount>1 ) + { + rSh.SplitTab(!bHorizontal, static_cast< USHORT >( nCount-1 ), bProportional ); + bCallDone = TRUE; + } + else + rReq.Ignore(); + } + break; + + case FN_TABLE_SPLIT_TABLE: + { + SFX_REQUEST_ARG( rReq, pType, SfxUInt16Item, FN_PARAM_1, sal_False ); + if( pType ) + { + switch( pType->GetValue() ) + { + case HEADLINE_NONE : + case HEADLINE_BORDERCOPY: + case HEADLINE_CNTNTCOPY: + case HEADLINE_BOXATTRCOPY: + case HEADLINE_BOXATRCOLLCOPY: + rSh.SplitTable(pType->GetValue()) ; + default: ;//wrong parameter, do nothing + } + } + else + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSplitTableDialog* pDlg = pFact->CreateSplitTblDialog( GetView().GetWindow(), rSh ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, pDlg->GetSplitMode() ) ); + delete pDlg; + bCallDone = sal_True; + } + } + break; + + case FN_TABLE_MERGE_TABLE: + { + BOOL bPrev = rSh.CanMergeTable( TRUE ); + BOOL bNext = rSh.CanMergeTable( FALSE ); + + if( bPrev && bNext ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + VclAbstractDialog* pDlg = pFact->CreateSwVclDialog( DLG_MERGE_TABLE, GetView().GetWindow(), bPrev ); + DBG_ASSERT(pDlg, "dialogdiet pDlg fail!"); + if( RET_OK != pDlg->Execute()) + bPrev = bNext = FALSE; + delete pDlg; + } + + if( bPrev || bNext ) + rSh.MergeTable( bPrev ); + } + break; + + case FN_TABLE_MODE_FIX : + case FN_TABLE_MODE_FIX_PROP : + case FN_TABLE_MODE_VARIABLE : + { + rSh.SetTblChgMode( ( FN_TABLE_MODE_FIX == nSlot ? TBLFIX_CHGABS + : FN_TABLE_MODE_FIX_PROP == nSlot + ? TBLFIX_CHGPROP + : TBLVAR_CHGABS ) ); + + SfxBindings& rBind = GetView().GetViewFrame()->GetBindings(); + static USHORT __READONLY_DATA aInva[] = + { FN_TABLE_MODE_FIX, + FN_TABLE_MODE_FIX_PROP, + FN_TABLE_MODE_VARIABLE, + 0 + }; + rBind.Invalidate( aInva ); + bCallDone = TRUE; + } + break; + case FN_TABLE_AUTOSUM: + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SFX_CALLMODE_SYNCHRON); + const USHORT nId = SwInputChild::GetChildWindowId(); + SwInputChild* pChildWin = (SwInputChild*)pVFrame-> + GetChildWindow( nId ); + String sSum; + GetShell().GetAutoSum(sSum); + if( pChildWin ) + pChildWin->SetFormula( sSum ); + + } + break; + case FN_TABLE_HEADLINE_REPEAT: + if(0 != rSh.GetRowsToRepeat()) + rSh.SetRowsToRepeat( 0 ); + else + rSh.SetRowsToRepeat(rSh.GetRowSelectionFromTop()); + break; + case FN_TABLE_SELECT_CELL : + rSh.SelectTableCell(); + break; + case FN_TABLE_DELETE_TABLE : + { + rSh.StartAction(); + rSh.StartUndo(); + rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL); + rSh.DeleteRow(); + rSh.EndUndo(); + rSh.EndAction(); + } + //'this' is already destroyed + return; + //break; + default: + bMore = TRUE; + } + + if ( !bMore ) + { + if(bCallDone) + rReq.Done(); + return; + } + else + bMore = FALSE; + //Jetzt die Slots, die direkt auf dem TableFmt arbeiten. + SwFrmFmt *pFmt = rSh.GetTableFmt(); + switch ( nSlot ) + { + case SID_ATTR_ULSPACE: + { + if(pItem) + { + SvxULSpaceItem aULSpace( *(const SvxULSpaceItem*)pItem ); + aULSpace.SetWhich( RES_UL_SPACE ); + ::lcl_SetAttr( rSh, aULSpace ); + } + } + break; + + case SID_ATTR_LRSPACE: + { + if(pItem) + { + SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE, + RES_HORI_ORIENT, RES_HORI_ORIENT, 0 ); + SvxLRSpaceItem aLRSpace( *(const SvxLRSpaceItem*)pItem ); + aLRSpace.SetWhich( RES_LR_SPACE ); + aSet.Put( aLRSpace ); + SwFmtHoriOrient aHori( pFmt->GetHoriOrient() ); + aHori.SetHoriOrient( text::HoriOrientation::NONE ); + aSet.Put( aLRSpace ); + rSh.SetTblAttr( aSet ); + } + } + break; +// der letzte case-Zweig der noch einen TabellenManager braucht!! + case FN_TABLE_SET_COL_WIDTH: + { + SwTableFUNC aMgr( &rSh, FALSE); + aMgr.ColWidthDlg(GetView().GetWindow()); + } + break; + case FN_TABLE_VERT_NONE: + case FN_TABLE_VERT_CENTER: + case FN_TABLE_VERT_BOTTOM: + { + USHORT nAlign = nSlot == FN_TABLE_VERT_NONE ? + text::VertOrientation::NONE : + nSlot == FN_TABLE_VERT_CENTER ? + text::VertOrientation::CENTER : text::VertOrientation::BOTTOM; + rSh.SetBoxAlign(nAlign); + bCallDone = TRUE; + } + break; + + case SID_ATTR_PARA_SPLIT: + if ( pItem ) + { + SwFmtLayoutSplit aSplit( ((const SvxFmtSplitItem*)pItem)->GetValue()); + SfxItemSet aSet(GetPool(), RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, 0 ); + aSet.Put(aSplit); + rSh.SetTblAttr(aSet); + } + break; + + case SID_ATTR_PARA_KEEP: + if ( pItem ) + { + SvxFmtKeepItem aKeep( *(const SvxFmtKeepItem*)pItem ); + aKeep.SetWhich( RES_KEEP ); + SfxItemSet aSet(GetPool(), RES_KEEP, RES_KEEP, 0 ); + aSet.Put(aKeep); + rSh.SetTblAttr(aSet); + } + break; + case FN_TABLE_ROW_SPLIT : + { + const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem); + SwFmtRowSplit* pSplit = 0; + if(!pBool) + { + rSh.GetRowSplit(pSplit); + if(pSplit) + pSplit->SetValue(!pSplit->GetValue()); + else + pSplit = new SwFmtRowSplit(TRUE); + } + else + { + pSplit = new SwFmtRowSplit(pBool->GetValue()); + } + rSh.SetRowSplit( *pSplit ); + delete pSplit; + } + break; + + default: + ASSERT( !this, "falscher Dispatcher" ); + return; + } + if(bCallDone) + rReq.Done(); +} +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwTableShell::GetState(SfxItemSet &rSet) +{ + SfxWhichIter aIter( rSet ); + SwWrtShell &rSh = GetShell(); + SwFrmFmt *pFmt = rSh.GetTableFmt(); + // os #124829# crash report: in case of an invalid shell selection return immediately + if(!pFmt) + return; + USHORT nSlot = aIter.FirstWhich(); + while ( nSlot ) + { + switch ( nSlot ) + { + case FN_TABLE_MERGE_CELLS: + if ( !rSh.IsTableMode() ) + rSet.DisableItem(FN_TABLE_MERGE_CELLS); + break; + case FN_TABLE_ADJUST_CELLS: + if ( !rSh.IsAdjustCellWidthAllowed() ) + rSet.DisableItem(FN_TABLE_ADJUST_CELLS); + break; + + case FN_TABLE_BALANCE_CELLS: + if ( !rSh.IsAdjustCellWidthAllowed(TRUE) ) + rSet.DisableItem(FN_TABLE_BALANCE_CELLS); + break; + + case FN_TABLE_BALANCE_ROWS: + if ( !rSh.BalanceRowHeight(TRUE) ) + rSet.DisableItem(FN_TABLE_BALANCE_ROWS); + break; + case FN_OPTIMIZE_TABLE: + if ( !rSh.IsTableMode() && + !rSh.IsAdjustCellWidthAllowed() && + !rSh.IsAdjustCellWidthAllowed(TRUE) && + !rSh.BalanceRowHeight(TRUE) ) + rSet.DisableItem(FN_OPTIMIZE_TABLE); + break; + case SID_INSERT_DIAGRAM: + { + SvtModuleOptions aMOpt; + if ( !aMOpt.IsMath() || rSh.IsTblComplexForChart() ) + rSet.DisableItem(nSlot); + } + break; + + case FN_INSERT_TABLE: + // Irgendeinen Wert "putten", damit Controller enabled bleibt. + // Statt "Insert:Table" erscheint dann "Format:Table". +// rSet.Put(SfxUInt16Item(nSlot, 1)); + break; + + case FN_TABLE_OPTIMAL_HEIGHT: + { + //Disablen wenn bereits auto-Hoehe eingestellt ist. + SwFmtFrmSize *pSz; + rSh.GetRowHeight( pSz ); + if ( pSz ) + { + if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() ) + rSet.DisableItem( nSlot ); + delete pSz; + } + } + break; + case FN_TABLE_INSERT_ROW: + case FN_TABLE_INSERT_ROW_DLG: + { + if ( rSh.IsInRepeatedHeadline() ) + rSet.DisableItem( nSlot ); + } + break; + case RES_LR_SPACE: + rSet.Put(pFmt->GetLRSpace()); + break; + case RES_UL_SPACE: + rSet.Put(pFmt->GetULSpace()); + break; + case FN_TABLE_VERT_NONE: + case FN_TABLE_VERT_CENTER: + case FN_TABLE_VERT_BOTTOM: + { + USHORT nAlign = rSh.GetBoxAlign(); + BOOL bSet = nSlot == FN_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE|| + nSlot == FN_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER || + nSlot == FN_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM; + rSet.Put(SfxBoolItem(nSlot, bSet)); + } + break; + + case FN_TABLE_MODE_FIX : + case FN_TABLE_MODE_FIX_PROP : + case FN_TABLE_MODE_VARIABLE : + { + TblChgMode nMode = rSh.GetTblChgMode(); + BOOL bSet = nSlot == FN_TABLE_MODE_FIX && nMode == TBLFIX_CHGABS || + nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TBLFIX_CHGPROP || + nSlot == FN_TABLE_MODE_VARIABLE && nMode == TBLVAR_CHGABS; + rSet.Put(SfxBoolItem(nSlot, bSet)); + } + break; + + case SID_ATTR_PARA_SPLIT: + rSet.Put( pFmt->GetKeep() ); + break; + + case SID_ATTR_PARA_KEEP: + rSet.Put( pFmt->GetLayoutSplit() ); + break; + case FN_TABLE_SPLIT_TABLE: + { + if ( rSh.IsInHeadline() ) + rSet.DisableItem( nSlot ); + } + break; + case FN_TABLE_MERGE_TABLE: + { + BOOL bAsk; + if( !rSh.CanMergeTable( TRUE, &bAsk )) + rSet.DisableItem( nSlot ); + } + break; + + case FN_TABLE_DELETE_ROW: + { + SwSelBoxes aBoxes; + ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW ); + if( ::HasProtectedCells( aBoxes )) + rSet.DisableItem( nSlot ); + } + break; + case FN_TABLE_DELETE_COL: + { + SwSelBoxes aBoxes; + ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_COL ); + if( ::HasProtectedCells( aBoxes )) + rSet.DisableItem( nSlot ); + } + break; + + case FN_TABLE_UNSET_READ_ONLY_CELLS: + // disable in readonly sections, but enable in protected cells + if( !rSh.CanUnProtectCells() ) + rSet.DisableItem( nSlot ); + break; + case RES_ROW_SPLIT: + { + const SwFmtLayoutSplit& rTabSplit = pFmt->GetLayoutSplit(); + if ( 0 == rTabSplit.GetValue() ) + { + rSet.DisableItem( nSlot ); + } + else + { + SwFmtRowSplit* pSplit = 0; + rSh.GetRowSplit(pSplit); + if(pSplit) + rSet.Put(*pSplit); + else + rSet.InvalidateItem( nSlot ); + delete pSplit; + } + } + break; + case FN_TABLE_HEADLINE_REPEAT: + if(0 != rSh.GetRowsToRepeat()) + rSet.Put(SfxBoolItem(nSlot, sal_True)); + else if(!rSh.GetRowSelectionFromTop()) + rSet.DisableItem( nSlot ); + else + rSet.Put(SfxBoolItem(nSlot, sal_False)); + break; + case FN_TABLE_SELECT_CELL : + if(rSh.HasBoxSelection()) + rSet.DisableItem( nSlot ); + break; + } + nSlot = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +SwTableShell::SwTableShell(SwView &_rView) : + SwBaseShell(_rView) +{ + SetName(String::CreateFromAscii("Table")); + SetHelpId(SW_TABSHELL); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwTableShell::GetFrmBorderState(SfxItemSet &rSet) +{ + SfxItemSet aCoreSet( GetPool(), + RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 ); + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + aCoreSet.Put( aBoxInfo ); + GetShell().GetTabBorders( aCoreSet ); + rSet.Put( aCoreSet ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwTableShell::ExecTableStyle(SfxRequest& rReq) +{ + SwWrtShell &rSh = GetShell(); + const SfxItemSet *pArgs = rReq.GetArgs(); + if(pArgs) + switch ( rReq.GetSlot() ) + { + case SID_FRAME_LINESTYLE: + case SID_FRAME_LINECOLOR: + { +/* Tabellenselektion ist abgeschafft + BOOL bPopCrsr = FALSE; + if ( !rReq.IsAPI() ) + { + //Keine Tabellenselektion -> Aenderung wird auf die gesamte + //Tabelle. + if ( !rSh.IsTableMode() ) + { + bPopCrsr = TRUE; + rSh.Push(); + rSh.StartAction(); + rSh.EnterStdMode(); + rSh.MoveTable( fnTableCurr, fnTableStart ); + rSh.SttSelect(); + rSh.MoveTable( fnTableCurr, fnTableEnd ); + rSh.EndSelect(); + } + }*/ + if ( rReq.GetSlot() == SID_FRAME_LINESTYLE ) + { + const SvxLineItem &rLineItem = (const SvxLineItem&)pArgs-> + Get( SID_FRAME_LINESTYLE ); + const SvxBorderLine* pBorderLine = rLineItem.GetLine(); + rSh.SetTabLineStyle( 0, TRUE, pBorderLine); + } + else + { + const SvxColorItem &rNewColorItem = (const SvxColorItem&)pArgs-> + Get( SID_FRAME_LINECOLOR ); + rSh.SetTabLineStyle( &rNewColorItem.GetValue() ); + } + + rReq.Done(); +/* if ( bPopCrsr ) + { + rSh.KillPams(); + rSh.Pop(FALSE); + rSh.EndAction(); + }*/ + break; + } + } +} + + +void SwTableShell::GetLineStyleState(SfxItemSet &rSet) +{ + SfxItemSet aCoreSet( GetPool(), + RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0); + SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER ); + aCoreSet.Put(aCoreInfo); + GetShell().GetTabBorders( aCoreSet ); + + const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aCoreSet.Get( RES_BOX ); + const SvxBorderLine* pLine = rBoxItem.GetTop(); + + rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) ); + SvxLineItem aLine( SID_FRAME_LINESTYLE ); + aLine.SetLine(pLine); + rSet.Put( aLine ); +} + +void SwTableShell::ExecNumberFormat(SfxRequest& rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + SwWrtShell &rSh = GetShell(); + + //Erstmal die Slots, die keinen FrmMgr benoetigen. + const SfxPoolItem* pItem = 0; + USHORT nSlot = rReq.GetSlot(); + if(pArgs) + pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem); + + // Sprache immer von Cursorposition besorgen + LanguageType eLang = rSh.GetCurLang(); + SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); + sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND; + USHORT nFmtType = 0, nOffset = 0; + + switch ( nSlot ) + { + case FN_NUMBER_FORMAT: + if( pItem ) + { + // Index fuer String bestimmen + String aCode( ((const SfxStringItem*)pItem)->GetValue() ); + nNumberFormat = pFormatter->GetEntryKey( aCode, eLang ); + if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat ) + { + // neu eintragen + xub_StrLen nErrPos; + short nType; + if( !pFormatter->PutEntry( aCode, nErrPos, nType, + nNumberFormat, eLang )) + nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND; + } + } + break; + case FN_NUMBER_STANDARD: nFmtType = NUMBERFORMAT_NUMBER; break; + case FN_NUMBER_SCIENTIFIC: nFmtType = NUMBERFORMAT_SCIENTIFIC; break; + case FN_NUMBER_DATE: nFmtType = NUMBERFORMAT_DATE; break; + case FN_NUMBER_TIME: nFmtType = NUMBERFORMAT_TIME; break; + case FN_NUMBER_CURRENCY: nFmtType = NUMBERFORMAT_CURRENCY; break; + case FN_NUMBER_PERCENT: nFmtType = NUMBERFORMAT_PERCENT; break; + + case FN_NUMBER_TWODEC: // #.##0,00 + nFmtType = NUMBERFORMAT_NUMBER; + nOffset = NF_NUMBER_1000DEC2; + break; + + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } + + if( nFmtType ) + nNumberFormat = pFormatter->GetStandardFormat( nFmtType, eLang ) + nOffset; + + if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat ) + { + SfxItemSet aBoxSet( GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT ); + aBoxSet.Put( SwTblBoxNumFormat( nNumberFormat )); + rSh.SetTblBoxFormulaAttrs( aBoxSet ); + } + +} + diff --git a/sw/source/ui/shells/textdrw.cxx b/sw/source/ui/shells/textdrw.cxx new file mode 100644 index 000000000000..5c6d043e0e01 --- /dev/null +++ b/sw/source/ui/shells/textdrw.cxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <svx/svdview.hxx> +#include <tools/urlobj.hxx> +#include <svx/fmglob.hxx> +#include <svx/svdouno.hxx> +#include <com/sun/star/form/FormButtonType.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <view.hxx> +#include <wrtsh.hxx> +#include <edtwin.hxx> +#include <swundo.hxx> +#include <basesh.hxx> + +#ifndef _POOLFMT_HRC +#include <poolfmt.hrc> +#endif + +#include <docsh.hxx> +#include <sfx2/docfile.hxx> +#include <svl/urihelper.hxx> +#include <avmedia/mediawindow.hxx> + +#include <unomid.h> + + +using namespace ::com::sun::star; +using ::rtl::OUString; +/*--------------------------------------------------------------------------- + Beschreibung: + ----------------------------------------------------------------------------*/ + +void SwBaseShell::InsertURLButton(const String& rURL, const String& rTarget, const String& rTxt) +{ + SwWrtShell& rSh = GetShell(); + + if (!rSh.HasDrawView()) + rSh.MakeDrawView(); + SdrView *pSdrView = rSh.GetDrawView(); + + // OBJ_FM_BUTTON + pSdrView->SetDesignMode(TRUE); + pSdrView->SetCurrentObj(OBJ_FM_BUTTON); + pSdrView->SetEditMode(sal_False); + + Point aStartPos(rSh.GetCharRect().Pos() + Point(0, 1)); + + rSh.StartAction(); + rSh.StartUndo( UNDO_UI_INSERT_URLBTN ); + if (rSh.BeginCreate(OBJ_FM_BUTTON, FmFormInventor, aStartPos)) + { + pSdrView->SetOrtho(sal_False); + Size aSz(GetView().GetEditWin().PixelToLogic(Size(140, 20))); + Point aEndPos(aSz.Width(), aSz.Height()); + + rSh.MoveCreate(aStartPos + aEndPos); + rSh.EndCreate(SDRCREATE_FORCEEND); + + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if (rMarkList.GetMark(0)) + { + SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj()); + uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel(); + + ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); + if( !xControlModel.is() ) + return; + + uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY); + + + uno::Any aTmp; + + aTmp <<= OUString(rTxt); + xPropSet->setPropertyValue( C2U("Label"), aTmp ); + + SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + + aTmp <<= OUString(URIHelper::SmartRel2Abs(aAbs, rURL)); + xPropSet->setPropertyValue( C2U("TargetURL"), aTmp ); + + if( rTarget.Len() ) + { + aTmp <<= OUString(rTarget); + xPropSet->setPropertyValue( C2U("TargetFrame"), aTmp ); + } + + + form::FormButtonType eButtonType = form::FormButtonType_URL; + aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0)); + xPropSet->setPropertyValue( C2U("ButtonType"), aTmp ); + + if ( ::avmedia::MediaWindow::isMediaURL( rURL ) ) + { + // #105638# OJ + aTmp <<= sal_True; + xPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), aTmp ); + } + } + + if (rSh.IsObjSelected()) + { +// rSh.ChgAnchor(FLY_AT_CNTNT); + rSh.UnSelectFrm(); + } + } + rSh.EndUndo( UNDO_UI_INSERT_URLBTN ); + rSh.EndAction(); +} + + diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx new file mode 100644 index 000000000000..a5093e8efcdd --- /dev/null +++ b/sw/source/ui/shells/textfld.cxx @@ -0,0 +1,889 @@ +/************ ************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <crsskip.hxx> +#include <hintids.hxx> //_immer_ vor den solar-Items + +#include <sfx2/lnkbase.hxx> +#include <fmtfld.hxx> +#include <tools/urlobj.hxx> +#include <vcl/msgbox.hxx> +#include <svl/itempool.hxx> +#include <unotools/useroptions.hxx> +#include <svl/whiter.hxx> +#include <svl/eitem.hxx> +#include <svl/macitem.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/request.hxx> +#include <svx/postattr.hxx> +#include <svx/hlnkitem.hxx> + +#include <svx/svxdlg.hxx> +#include <sfx2/linkmgr.hxx> +#include <unotools/localedatawrapper.hxx> +#include <sfx2/dispatch.hxx> +#include <fmtinfmt.hxx> +#include <fldwrap.hxx> +#include <redline.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <basesh.hxx> +#include <wrtsh.hxx> +#include <flddat.hxx> +#include <numrule.hxx> +#include <textsh.hxx> +#include <docsh.hxx> +#include <docufld.hxx> +#include <usrfld.hxx> +#include <ddefld.hxx> +#include <expfld.hxx> +#include <fldmgr.hxx> +#include <uitool.hxx> + +#include <cmdid.h> +#include <shells.hrc> + +#include <sfx2/app.hxx> +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include "swabstdlg.hxx" +#include "dialog.hrc" +#include <fldui.hrc> +#include <doc.hxx> + +#include <app.hrc> + +#include "PostItMgr.hxx" +#include "postit.hxx" + +using namespace nsSwDocInfoSubType; + + +extern BOOL bNoInterrupt; // in mainwn.cxx + +String& lcl_AppendRedlineStr( String& rStr, USHORT nRedlId ) +{ + USHORT nResId = 0; + switch( nRedlId ) + { + case nsRedlineType_t::REDLINE_INSERT: nResId = STR_REDLINE_INSERTED; break; + case nsRedlineType_t::REDLINE_DELETE: nResId = STR_REDLINE_DELETED; break; + case nsRedlineType_t::REDLINE_FORMAT: nResId = STR_REDLINE_FORMATED; break; + case nsRedlineType_t::REDLINE_TABLE: nResId = STR_REDLINE_TABLECHG; break; + case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLLSET; break; + } + if( nResId ) + rStr += SW_RESSTR( nResId ); + return rStr; +} + +// STATIC DATA ----------------------------------------------------------- + +void SwTextShell::ExecField(SfxRequest &rReq) +{ + SwWrtShell& rSh = GetShell(); + const SfxPoolItem* pItem = 0; + + USHORT nSlot = rReq.GetSlot(); + const SfxItemSet* pArgs = rReq.GetArgs(); + if(pArgs) + pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem); + + Window *pMDI = &GetView().GetViewFrame()->GetWindow(); + BOOL bMore = FALSE; + BOOL bIsText = TRUE; + USHORT nInsertType = 0; + USHORT nInsertSubType = 0; + ULONG nInsertFormat = 0; + + switch(nSlot) + { + case FN_EDIT_FIELD: + { + SwField* pFld = rSh.GetCurFld(); + if( pFld ) + { + switch ( pFld->GetTypeId() ) + { + case TYP_DDEFLD: + { + ::sfx2::SvBaseLink& rLink = ((SwDDEFieldType*)pFld->GetTyp())-> + GetBaseLink(); + if(rLink.IsVisible()) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pMDI, &rSh.GetLinkManager(), FALSE, &rLink ); + if ( pDlg ) + { + pDlg->Execute(); + delete pDlg; + } + } + break; + } + default: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractDialog* pDlg = pFact->CreateSwFldEditDlg( GetView(),RC_DLG_SWFLDEDITDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + } + } + break; + } + case FN_EXECUTE_MACROFIELD: + { + SwField* pFld = rSh.GetCurFld(); + if(pFld && pFld->GetTyp()->Which() == RES_MACROFLD) + { + + const String& rMacro = ((SwMacroField*)pFld)->GetMacro(); + USHORT nPos = rMacro.Search('.', 0); + if(nPos != STRING_NOTFOUND) + { + SvxMacro aMacro( rMacro.Copy(nPos + 1), rMacro.Copy(0,nPos), STARBASIC ); + rSh.ExecMacro(aMacro); + } + } + } + break; + + case FN_GOTO_NEXT_INPUTFLD: + case FN_GOTO_PREV_INPUTFLD: + { + BOOL bRet = FALSE; + SwFieldType* pFld = rSh.GetFldType( 0, RES_INPUTFLD ); + if( pFld && rSh.MoveFldType( pFld, + FN_GOTO_NEXT_INPUTFLD == nSlot )) + { + rSh.ClearMark(); + rSh.StartInputFldDlg( rSh.GetCurFld(), FALSE ); + bRet = TRUE; + } + + rReq.SetReturnValue( SfxBoolItem( nSlot, bRet )); + } + break; + + default: + bMore = TRUE; + } + if(bMore) + { + // hier kommen die Slots mit FldMgr + SwFldMgr aFldMgr(GetShellPtr()); + switch(nSlot) + { + case FN_INSERT_DBFIELD: + { + BOOL bRes = FALSE; + if( pItem ) + { + ULONG nFormat = 0; + USHORT nType = 0; + String aPar1 = ((SfxStringItem *)pItem)->GetValue(); + String aPar2; + sal_Int32 nCommand = 0; + + if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, + FALSE, &pItem )) + nType = ((SfxUInt16Item *)pItem)->GetValue(); + aPar1 += DB_DELIM; + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_1, FALSE, &pItem )) + { + aPar1 += ((SfxStringItem *)pItem)->GetValue(); + } + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_3, FALSE, &pItem )) + nCommand = ((SfxInt32Item*)pItem)->GetValue(); + aPar1 += DB_DELIM; + aPar1 += String::CreateFromInt32(nCommand); + aPar1 += DB_DELIM; + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_2, FALSE, &pItem )) + { + aPar1 += ((SfxStringItem *)pItem)->GetValue(); + } + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_FIELD_CONTENT, FALSE, &pItem )) + aPar2 = ((SfxStringItem *)pItem)->GetValue(); + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_FIELD_FORMAT, FALSE, &pItem )) + nFormat = ((SfxUInt32Item *)pItem)->GetValue(); + DBG_WARNING("Command is not yet used"); + sal_Unicode cSeparator = ' '; + SwInsertFld_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator ); + bRes = aFldMgr.InsertFld(aData); + } + rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); + } + break; + case FN_INSERT_FIELD_CTRL: + case FN_INSERT_FIELD: + { + BOOL bRes = FALSE; + if( pItem && nSlot != FN_INSERT_FIELD_CTRL) + { + ULONG nFormat = 0; + USHORT nType = 0; + USHORT nSubType = 0; + String aPar1 = ((SfxStringItem *)pItem)->GetValue(); + String aPar2; + sal_Unicode cSeparator = ' '; + + if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, + FALSE, &pItem )) + nType = ((SfxUInt16Item *)pItem)->GetValue(); + if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE, + FALSE, &pItem )) + nSubType = ((SfxUInt16Item *)pItem)->GetValue(); + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_FIELD_CONTENT, FALSE, &pItem )) + aPar2 = ((SfxStringItem *)pItem)->GetValue(); + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_FIELD_FORMAT, FALSE, &pItem )) + nFormat = ((SfxUInt32Item *)pItem)->GetValue(); + if( SFX_ITEM_SET == pArgs->GetItemState( + FN_PARAM_3, FALSE, &pItem )) + { + String sTmp = ((SfxStringItem *)pItem)->GetValue(); + if(sTmp.Len()) + cSeparator = sTmp.GetChar(0); + } + SwInsertFld_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator ); + bRes = aFldMgr.InsertFld( aData ); + } + else + //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active + if(!GetView().GetViewFrame()->IsInModalMode()) + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + pVFrame->ToggleChildWindow(FN_INSERT_FIELD); + bRes = pVFrame->GetChildWindow( nSlot ) != 0; + Invalidate(rReq.GetSlot()); + Invalidate(FN_INSERT_FIELD_CTRL); + rReq.Ignore(); + } + rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); + } + break; + + case FN_INSERT_REF_FIELD: + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (!pVFrame->HasChildWindow(FN_INSERT_FIELD)) + pVFrame->ToggleChildWindow(FN_INSERT_FIELD); // Dialog anzeigen + + // Flddlg auf neue TabPage umschalten + USHORT nId = SwFldDlgWrapper::GetChildWindowId(); + SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId); + if (pWrp) + pWrp->ShowPage(); + rReq.Ignore(); + } + break; + case FN_DELETE_NOTE: + if ( GetView().GetPostItMgr() && GetView().GetPostItMgr()->GetActivePostIt() ) + GetView().GetPostItMgr()->GetActivePostIt()->Delete(); + break; + case FN_DELETE_ALL_NOTES: + if ( GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Delete(); + break; + case FN_DELETE_NOTE_AUTHOR: + { + SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, FALSE); + if ( pNoteItem && GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() ); + } + break; + case FN_HIDE_NOTE: + if ( GetView().GetPostItMgr() && GetView().GetPostItMgr()->GetActivePostIt() ) + GetView().GetPostItMgr()->GetActivePostIt()->Hide(); + break; + case FN_HIDE_ALL_NOTES: + if ( GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Hide(); + break; + case FN_HIDE_NOTE_AUTHOR: + { + SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, FALSE); + if ( pNoteItem && GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() ); + } + break; + case FN_POSTIT: + { + SwPostItField* pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); + BOOL bNew = !(pPostIt && pPostIt->GetTyp()->Which() == RES_POSTITFLD); + if (bNew || GetView().GetPostItMgr()->IsAnswer()) + { + SvtUserOptions aUserOpt; + String sAuthor; + if( !(sAuthor = aUserOpt.GetFullName()).Len()) + if( !(sAuthor = aUserOpt.GetID()).Len() ) + sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); + if( rSh.HasSelection() ) + { + rSh.NormalizePam(true); + rSh.KillPams(); + rSh.ClearMark(); + } + SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0); + aFldMgr.InsertFld(aData); + rSh.Push(); + rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, FALSE); + pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); + rSh.Pop(FALSE); // Cursorpos restaurieren + } + + if (pPostIt) + { + SwFieldType* pType = rSh.GetDoc()->GetFldType(RES_POSTITFLD, aEmptyStr,false); + SwClientIter aIter( *pType ); + SwClient* pFirst = aIter.GoStart(); + while( pFirst ) + { + SwFmtFld* pSwFmtFld = static_cast<SwFmtFld*>(pFirst); + if ( pSwFmtFld->GetFld() == pPostIt ) + { + pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) ); + break; + } + pFirst = aIter++; + } + } + } + break; + case FN_REDLINE_COMMENT: + { + /* this code can be used once we want redline comments in the margin, all other stuff can + then be deleted + String sComment; + const SwRedline *pRedline = rSh.GetCurrRedline(); + + if (pRedline) + { + sComment = pRedline->GetComment(); + if ( sComment == String(rtl::OUString::createFromAscii("")) ) + GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); + const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); + } + */ + + String sComment; + const SwRedline *pRedline = rSh.GetCurrRedline(); + + if (pRedline) + { + sComment = pRedline->GetComment(); + + + BOOL bTravel = FALSE; + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT ); + DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()"); + SfxItemSet aSet(GetPool(), fnGetRange()); + aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT)); + aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); + + aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString( + pRedline->GetRedlineData().GetTimeStamp() ), + SID_ATTR_POSTIT_DATE )); + + // Traveling nur bei mehr als einem Feld + rSh.StartAction(); + + rSh.Push(); + const SwRedline *pActRed = rSh.SelPrevRedline(); + + if (pActRed == pRedline) + { // Neuer Cursor steht am Anfang des Current Redlines + rSh.Pop(); // Alten Cursor wegwerfen + rSh.Push(); + pActRed = rSh.SelPrevRedline(); + } + + BOOL bPrev = pActRed != 0; + rSh.Pop(FALSE); + rSh.EndAction(); + + rSh.ClearMark(); + rSh.SelNextRedline(); // Aktueller Redline wird selektiert + + rSh.StartAction(); + rSh.Push(); + pActRed = rSh.SelNextRedline(); + BOOL bNext = pActRed != 0; + rSh.Pop(FALSE); // Cursorpos restaurieren + + if( rSh.IsCrsrPtAtEnd() ) + rSh.SwapPam(); + + rSh.EndAction(); + + bTravel |= bNext|bPrev; + + SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact2, "Dialogdiet fail!"); + AbstractSvxPostItDialog* pDlg = pFact2->CreateSvxPostItDialog( pMDI, aSet, bTravel, TRUE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->HideAuthor(); + + String sTitle(SW_RES(STR_REDLINE_COMMENT)); + ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); + + pDlg->SetText(sTitle); + + if (bTravel) + { + pDlg->EnableTravel(bNext, bPrev); + pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl)); + pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl)); + } + + rSh.SetCareWin(pDlg->GetWindow()); + bNoInterrupt = TRUE; + + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); + + // Kommentar einfuegen bzw aendern + rSh.SetRedlineComment(sMsg); + } + + delete pDlg; + rSh.SetCareWin(NULL); + bNoInterrupt = FALSE; + rSh.ClearMark(); + GetView().AttrChangedNotify(GetShellPtr()); + } + } + break; + + case FN_JAVAEDIT: + { + String aType, aText; + BOOL bIsUrl=FALSE; + BOOL bNew=FALSE, bUpdate=FALSE; + SwFldMgr* pMgr = new SwFldMgr; + if ( pItem ) + { + aText = ((SfxStringItem*)pItem)->GetValue(); + SFX_REQUEST_ARG( rReq, pType, SfxStringItem, FN_PARAM_2 , sal_False ); + SFX_REQUEST_ARG( rReq, pIsUrl, SfxBoolItem, FN_PARAM_1 , sal_False ); + if ( pType ) + aType = pType->GetValue(); + if ( pIsUrl ) + bIsUrl = pIsUrl->GetValue(); + + SwScriptField* pFld = (SwScriptField*)pMgr->GetCurFld(); + bNew = !pFld || !(pFld->GetTyp()->Which() == RES_SCRIPTFLD); + bUpdate = pFld && ( bIsUrl != pFld->GetFormat() || pFld->GetPar2() != aType || pFld->GetPar1() != aText ); + } + else + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractJavaEditDialog* pDlg = pFact->CreateJavaEditDialog( DLG_JAVAEDIT, + pMDI, &rSh); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() ) + { + aType = pDlg->GetType(); + aText = pDlg->GetText(); + bIsUrl = pDlg->IsUrl(); + bNew = pDlg->IsNew(); + bUpdate = pDlg->IsUpdate(); + rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) ); + rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) ); + } + + delete pDlg; + } + + if( bNew ) + { + SwInsertFld_Data aData(TYP_SCRIPTFLD, 0, aType, aText, bIsUrl); + pMgr->InsertFld(aData); + rReq.Done(); + } + else if( bUpdate ) + { + pMgr->UpdateCurFld( bIsUrl, aType, aText ); + rSh.SetUndoNoResetModified(); + rReq.Done(); + } + else + rReq.Ignore(); + } + break; + + case FN_INSERT_FLD_DATE : + nInsertType = TYP_DATEFLD; + bIsText = FALSE; + goto FIELD_INSERT; + case FN_INSERT_FLD_TIME : + nInsertType = TYP_TIMEFLD; + bIsText = FALSE; + goto FIELD_INSERT; + case FN_INSERT_FLD_PGNUMBER: + nInsertType = TYP_PAGENUMBERFLD; + nInsertFormat = SVX_NUM_PAGEDESC; // wie Seitenvorlage + bIsText = FALSE; + goto FIELD_INSERT; + case FN_INSERT_FLD_PGCOUNT : + nInsertType = TYP_DOCSTATFLD; + nInsertSubType = 0; + bIsText = FALSE; + nInsertFormat = SVX_NUM_PAGEDESC; + goto FIELD_INSERT; + case FN_INSERT_FLD_TOPIC : + nInsertType = TYP_DOCINFOFLD; + nInsertSubType = DI_THEMA; + goto FIELD_INSERT; + case FN_INSERT_FLD_TITLE : + nInsertType = TYP_DOCINFOFLD; + nInsertSubType = DI_TITEL; + goto FIELD_INSERT; + case FN_INSERT_FLD_AUTHOR : + nInsertType = TYP_DOCINFOFLD; + nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; + +FIELD_INSERT: + { + //format conversion should only be done for number formatter formats + if(!nInsertFormat) + nInsertFormat = aFldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter()); + SwInsertFld_Data aData(nInsertType, nInsertSubType, + aEmptyStr, aEmptyStr, nInsertFormat); + aFldMgr.InsertFld(aData); + rReq.Done(); + } + break; + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } + } +} + +void SwTextShell::StateField( SfxItemSet &rSet ) +{ + SwWrtShell& rSh = GetShell(); + SfxWhichIter aIter( rSet ); + const SwField* pField = 0; + int bGetField = FALSE; + USHORT nWhich = aIter.FirstWhich(); + + while (nWhich) + { + switch (nWhich) + { + case FN_DELETE_NOTE: + case FN_DELETE_NOTE_AUTHOR: + case FN_DELETE_ALL_NOTES: + case FN_HIDE_NOTE: + case FN_HIDE_NOTE_AUTHOR: + case FN_HIDE_ALL_NOTES: + { + SwPostItMgr* pPostItMgr = GetView().GetPostItMgr(); + if ( !pPostItMgr ) + rSet.InvalidateItem( nWhich ); + else if ( !pPostItMgr->GetActivePostIt() ) + { + rSet.InvalidateItem( FN_DELETE_NOTE ); + rSet.InvalidateItem( FN_HIDE_NOTE ); + } + } + break; + case FN_EDIT_FIELD: + { + /* #108536# Fields can be selected, too now. Removed + + if( rSh.HasSelection() ) + rSet.DisableItem(nWhich); + else ... + */ + + if( !bGetField ) + { + pField = rSh.GetCurFld(); + bGetField = TRUE; + } + + USHORT nTempWhich = pField ? pField->GetTyp()->Which() : USHRT_MAX; + if( USHRT_MAX == nTempWhich || + RES_POSTITFLD == nTempWhich || + RES_SCRIPTFLD == nTempWhich || + RES_AUTHORITY == nTempWhich ) + rSet.DisableItem( nWhich ); + else if( RES_DDEFLD == nTempWhich && + !((SwDDEFieldType*)pField->GetTyp())->GetBaseLink().IsVisible()) + { + // nested links cannot be edited + rSet.DisableItem( nWhich ); + } + } + break; + case FN_EXECUTE_MACROFIELD: + { + if(!bGetField) + { + pField = rSh.GetCurFld(); + bGetField = TRUE; + } + if(!pField || pField->GetTyp()->Which() != RES_MACROFLD) + rSet.DisableItem(nWhich); + } + break; + + case FN_INSERT_FIELD: + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active + if(!pVFrame->IsInModalMode() && + pVFrame->KnowsChildWindow(FN_INSERT_FIELD) && !pVFrame->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY) ) + rSet.Put(SfxBoolItem( FN_INSERT_FIELD, pVFrame->HasChildWindow(nWhich))); + else + rSet.DisableItem(FN_INSERT_FIELD); + } + break; + case FN_INSERT_REF_FIELD: + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (!pVFrame->KnowsChildWindow(FN_INSERT_FIELD)) + rSet.DisableItem(FN_INSERT_REF_FIELD); + } + break; + case FN_INSERT_FIELD_CTRL: + rSet.Put(SfxBoolItem( nWhich, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD))); + break; + case FN_REDLINE_COMMENT: + if (!rSh.GetCurrRedline()) + rSet.DisableItem(nWhich); + break; + case FN_POSTIT : + case FN_JAVAEDIT : + BOOL bCurField = FALSE; + pField = rSh.GetCurFld(); + if(nWhich == FN_POSTIT) + bCurField = pField && pField->GetTyp()->Which() == RES_POSTITFLD; + else + bCurField = pField && pField->GetTyp()->Which() == RES_SCRIPTFLD; + + if(!bCurField && rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() ) + rSet.DisableItem(nWhich); + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*--------------------------------------------------------------------------- + Beschreibung: + ----------------------------------------------------------------------------*/ + + +void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem) +{ + const String& rName = rHlnkItem.GetName(); + const String& rURL = rHlnkItem.GetURL(); + const String& rTarget = rHlnkItem.GetTargetFrame(); + USHORT nType = (USHORT)rHlnkItem.GetInsertMode(); + nType &= ~HLINK_HTMLMODE; + const SvxMacroTableDtor* pMacroTbl = rHlnkItem.GetMacroTbl(); + + SwWrtShell& rSh = GetShell(); + + if( rSh.GetSelectionType() & nsSelectionType::SEL_TXT ) + { + rSh.StartAction(); + SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); + rSh.GetCurAttr( aSet ); + + const SfxPoolItem* pItem; + if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, FALSE, &pItem)) + { + // Links selektieren + rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT, FALSE); + } + switch (nType) + { + case HLINK_DEFAULT: + case HLINK_FIELD: + { + SwFmtINetFmt aINetFmt( rURL, rTarget ); + aINetFmt.SetName(rHlnkItem.GetIntName()); + if(pMacroTbl) + { + SvxMacro *pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOVER_OBJECT ); + if( pMacro ) + aINetFmt.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT, *pMacro); + pMacro = pMacroTbl->Get( SFX_EVENT_MOUSECLICK_OBJECT ); + if( pMacro ) + aINetFmt.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT, *pMacro); + pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOUT_OBJECT ); + if( pMacro ) + aINetFmt.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT, *pMacro); + } + rSh.SttSelect(); + rSh.InsertURL( aINetFmt, rName, TRUE ); + rSh.EndSelect(); + } + break; + + case HLINK_BUTTON: + BOOL bSel = rSh.HasSelection(); + if(bSel) + rSh.DelRight(); + InsertURLButton( rURL, rTarget, rName ); + rSh.EnterStdMode(); + break; + } + rSh.EndAction(); + } +} + +IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog *, pBtn ) +{ + SwWrtShell* pSh = GetShellPtr(); + AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn; + + // Kommentar einfuegen bzw aendern + pSh->SetRedlineComment(pDlg->GetNote()); + + const SwRedline *pRedline = pSh->GetCurrRedline(); + + String sComment; + + if (pRedline) + { + // Traveling nur bei mehr als einem Feld + if( !pSh->IsCrsrPtAtEnd() ) + pSh->SwapPam(); // Cursor hinter den Redline stellen + + pSh->Push(); + const SwRedline *pActRed = pSh->SelNextRedline(); + pSh->Pop(pActRed != 0); + + BOOL bEnable = FALSE; + + if (pActRed) + { + pSh->StartAction(); + pSh->Push(); + bEnable = pSh->SelNextRedline() != 0; + pSh->Pop(FALSE); + pSh->EndAction(); + } + + pDlg->EnableTravel(bEnable, TRUE); + + if( pSh->IsCrsrPtAtEnd() ) + pSh->SwapPam(); + + pRedline = pSh->GetCurrRedline(); + sComment = pRedline->GetComment(); + + pDlg->SetNote( sComment.ConvertLineEnd() ); + pDlg->ShowLastAuthor( pRedline->GetAuthorString(), + GetAppLangDateTimeString( + pRedline->GetRedlineData().GetTimeStamp() )); + + String sTitle(SW_RES(STR_REDLINE_COMMENT)); + ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); + + pDlg->SetText(sTitle); + } + + return 0; +} + +IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn ) +{ + SwWrtShell* pSh = GetShellPtr(); + AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn; + + // Kommentar einfuegen bzw aendern + pSh->SetRedlineComment(pDlg->GetNote()); + + const SwRedline *pRedline = pSh->GetCurrRedline(); + + String sComment; + + if (pRedline) + { + // Traveling nur bei mehr als einem Feld + pSh->Push(); + const SwRedline *pActRed = pSh->SelPrevRedline(); + pSh->Pop(pActRed != 0); + + BOOL bEnable = FALSE; + + if (pActRed) + { + pSh->StartAction(); + pSh->Push(); + bEnable = pSh->SelPrevRedline() != 0; + pSh->Pop(FALSE); + pSh->EndAction(); + } + + pDlg->EnableTravel(TRUE, bEnable); + + pRedline = pSh->GetCurrRedline(); + sComment = pRedline->GetComment(); + + pDlg->SetNote(sComment.ConvertLineEnd()); + pDlg->ShowLastAuthor(pRedline->GetAuthorString(), + GetAppLangDateTimeString( + pRedline->GetRedlineData().GetTimeStamp() )); + + String sTitle(SW_RES(STR_REDLINE_COMMENT)); + ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); + + pDlg->SetText(sTitle); + } + + return 0; +} + + diff --git a/sw/source/ui/shells/textglos.cxx b/sw/source/ui/shells/textglos.cxx new file mode 100644 index 000000000000..a1a9f87ca918 --- /dev/null +++ b/sw/source/ui/shells/textglos.cxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <sfx2/request.hxx> +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> + +#include "errhdl.hxx" +#include "view.hxx" +#include "initui.hxx" +#include "cmdid.h" +#include "textsh.hxx" +#include "initui.hxx" +#include "gloshdl.hxx" +#include "glosdoc.hxx" +#include "gloslst.hxx" +#include "swabstdlg.hxx" +#include <misc.hrc> + +// STATIC DATA ----------------------------------------------------------- + +void SwTextShell::ExecGlossary(SfxRequest &rReq) +{ + USHORT nSlot = rReq.GetSlot(); + ::GetGlossaries()->UpdateGlosPath(!rReq.IsAPI() || + FN_GLOSSARY_DLG == nSlot ); + SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl(); + // SwGlossaryList updaten? + BOOL bUpdateList = FALSE; + + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + if(pArgs) + pArgs->GetItemState(nSlot, FALSE, &pItem ); + + switch( nSlot ) + { + case FN_GLOSSARY_DLG: + pGlosHdl->GlossaryDlg(); + bUpdateList = TRUE; + rReq.Ignore(); + break; + case FN_EXPAND_GLOSSARY: + { + BOOL bReturn; + bReturn = pGlosHdl->ExpandGlossary(); + rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) ); + rReq.Done(); + } + break; + case FN_NEW_GLOSSARY: + if(pItem && pArgs->Count() == 3 ) + { + String aGroup = (( const SfxStringItem *)pItem)->GetValue(); + String aName; + if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem )) + aName = (( const SfxStringItem *)pItem)->GetValue(); + String aShortName; + if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_2, FALSE, &pItem )) + aShortName = (( const SfxStringItem *)pItem)->GetValue(); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); + if ( fnSetActGroup ) + (*fnSetActGroup)( aGroup ); + pGlosHdl->SetCurGroup(aGroup, TRUE); + //eingestellte Gruppe muss in NewGlossary ggf. erzeugt werden! + pGlosHdl->NewGlossary( aName, aShortName, TRUE ); + rReq.Done(); + } + bUpdateList = TRUE; + break; + case FN_SET_ACT_GLOSSARY: + if(pItem) + { + String aGroup = (( const SfxStringItem *)pItem)->GetValue(); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); + if ( fnSetActGroup ) + (*fnSetActGroup)( aGroup ); + rReq.Done(); + } + break; + case FN_INSERT_GLOSSARY: + { + if(pItem && pArgs->Count() > 1) + { + String aGroup = (( const SfxStringItem *)pItem)->GetValue(); + String aName; + if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem )) + aName = (( const SfxStringItem *)pItem)->GetValue(); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); + if ( fnSetActGroup ) + (*fnSetActGroup)( aGroup ); + pGlosHdl->SetCurGroup(aGroup, TRUE); + rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName ))); + rReq.Done(); + } + } + break; + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } + if(bUpdateList) + { + SwGlossaryList* pList = ::GetGlossaryList(); + if(pList->IsActive()) + pList->Update(); + } +} + + diff --git a/sw/source/ui/shells/textidx.cxx b/sw/source/ui/shells/textidx.cxx new file mode 100644 index 000000000000..135a3435ca31 --- /dev/null +++ b/sw/source/ui/shells/textidx.cxx @@ -0,0 +1,261 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> +#include <vcl/msgbox.hxx> +#include <sfx2/request.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> +#include <editeng/sizeitem.hxx> +#include <fmtfsize.hxx> +#include <fldbas.hxx> +#include <uiitems.hxx> +#include "viewopt.hxx" +#include "cmdid.h" +#include "view.hxx" +#include "wrtsh.hxx" +#include "swundo.hxx" // fuer Undo-Ids +#include "textsh.hxx" +#include "idxmrk.hxx" +#include "cnttab.hxx" +#include "toxmgr.hxx" +#include "swabstdlg.hxx" +#include <index.hrc> +#include <globals.hrc> + + +// STATIC DATA ----------------------------------------------------------- + +void SwTextShell::ExecIdx(SfxRequest &rReq) +{ + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + USHORT nSlot = rReq.GetSlot(); + if(pArgs) + pArgs->GetItemState(nSlot, FALSE, &pItem ); + + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + Window *pMDI = &pVFrame->GetWindow(); + + switch( nSlot ) + { + case FN_EDIT_AUTH_ENTRY_DLG : + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( pMDI, GetShell(), DLG_EDIT_AUTHMARK); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + break; + case FN_INSERT_AUTH_ENTRY_DLG: + { + // no BASIC support + pVFrame->ToggleChildWindow(FN_INSERT_AUTH_ENTRY_DLG); + Invalidate(rReq.GetSlot()); + } + break; + case FN_INSERT_IDX_ENTRY_DLG: + { + pVFrame->ToggleChildWindow(FN_INSERT_IDX_ENTRY_DLG); + Invalidate(rReq.GetSlot()); + } + break; + case FN_EDIT_IDX_ENTRY_DLG: + { + SwTOXMgr aMgr(GetShellPtr()); + USHORT nRet = RET_OK; + if(aMgr.GetTOXMarkCount() > 1) + { // Mehrere Marken, welche solls denn sein ? + // + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + VclAbstractDialog* pMultDlg = pFact->CreateMultiTOXMarkDlg( DLG_MULTMRK, + pMDI, aMgr); + DBG_ASSERT(pMultDlg, "Dialogdiet fail!"); + nRet = pMultDlg->Execute(); + delete pMultDlg; + } + if( nRet == RET_OK) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + VclAbstractDialog* pDlg = pFact->CreateIndexMarkModalDlg( DLG_EDIT_IDXMARK, pMDI, GetShell(), aMgr.GetCurTOXMark() ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + break; + } + case FN_IDX_MARK_TO_IDX: + { + GetShell().GotoTOXMarkBase(); + break; + } + case FN_INSERT_MULTI_TOX: + { + SfxItemSet aSet(GetPool(), + RES_COL, RES_COL, + RES_BACKGROUND, RES_BACKGROUND, + RES_FRM_SIZE, RES_FRM_SIZE, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + RES_LR_SPACE, RES_LR_SPACE, + FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE, + 0 ); + SwWrtShell& rSh = GetShell(); + SwRect aRect; + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); + + long nWidth = aRect.Width(); + aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); + // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) + aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); + const SwTOXBase* pCurTOX = 0; + BOOL bGlobal = FALSE; + if(pItem) + { + pCurTOX = (const SwTOXBase* )((SwPtrItem*)pItem)->GetValue(); + bGlobal = TRUE; + } + else + pCurTOX = rSh.GetCurTOX(); + if(pCurTOX) + { + const SfxItemSet* pSet = pCurTOX->GetAttrSet(); + if(pSet) + aSet.Put(*pSet); + } + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX, + pMDI, aSet, rSh, (SwTOXBase* )pCurTOX, + USHRT_MAX, bGlobal); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + break; + case FN_REMOVE_CUR_TOX: + { + SwWrtShell& rSh = GetShell(); + const SwTOXBase* pBase = rSh.GetCurTOX(); + DBG_ASSERT(pBase, "no TOXBase to remove"); + if( pBase ) + rSh.DeleteTOX(*pBase, TRUE); + } + break; + default: + ASSERT(!this, falscher Dispatcher); + return; + } +} + + +void SwTextShell::GetIdxState(SfxItemSet &rSet) +{ + SwWrtShell& rSh = GetShell(); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*) + pVFrame->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG); + + SfxChildWindow* pAuthMark = pVFrame->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG); + + const BOOL bHtmlMode = 0 != ::GetHtmlMode( GetView().GetDocShell() ); + const SwTOXBase* pBase = 0; + if( bHtmlMode || 0 != ( pBase = rSh.GetCurTOX()) ) + { + if( pBase ) + { + if(pBase->IsTOXBaseInReadonly()) + { + rSet.DisableItem( FN_INSERT_MULTI_TOX ); + } + } + + rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG ); + rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG ); + + if(!pIdxMrk) + rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG ); + else + rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, TRUE)); + + if(!pAuthMark) + rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG ); + else + rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, TRUE)); + + } + else //if( SFX_ITEM_UNKNOWN != rSet.GetItemState( FN_EDIT_IDX_ENTRY_DLG )) + { + + BOOL bEnableEdit = TRUE; + BOOL bInReadonly = rSh.HasReadonlySel(); + if( rSh.HasSelection() || bInReadonly) + bEnableEdit = FALSE; + else + { + SwTOXMarks aArr; + rSh.GetCurTOXMarks( aArr ); + if( !aArr.Count()) + bEnableEdit = FALSE; + } + + if(!bEnableEdit) + rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG ); + + if(bInReadonly) + { + rSet.DisableItem(FN_INSERT_IDX_ENTRY_DLG); + rSet.DisableItem( FN_INSERT_MULTI_TOX ); + } + else + rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, + 0 != pIdxMrk)); + + + SwField* pField = rSh.GetCurFld(); + + if(bInReadonly) + rSet.DisableItem(FN_INSERT_AUTH_ENTRY_DLG); + else + rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, 0 != pAuthMark)); + + if( bInReadonly || !pField || + pField->GetTyp()->Which() != RES_AUTHORITY) + rSet.DisableItem(FN_EDIT_AUTH_ENTRY_DLG); + rSet.DisableItem(FN_REMOVE_CUR_TOX); + } +} + +// ----------------------------------------------------------------------- + diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx new file mode 100644 index 000000000000..c2308b9def0a --- /dev/null +++ b/sw/source/ui/shells/textsh.cxx @@ -0,0 +1,1260 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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" + + +#define _SW_FRMVALID_HXX +#include <hintids.hxx> + +#include <svl/globalnameitem.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/lnkbase.hxx> + +#include <tools/errinf.hxx> +#include <svx/svdview.hxx> +#include <svl/ptitem.hxx> +#include <svl/stritem.hxx> +#include <unotools/moduleoptions.hxx> +#include <vcl/msgbox.hxx> +#include <sfx2/fcontnr.hxx> +#include <svx/hlnkitem.hxx> +#include <svl/srchitem.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/docfile.hxx> +#include <svl/urihelper.hxx> +#include <basic/sbxvar.hxx> +#include <svl/whiter.hxx> +#include <sfx2/request.hxx> +#include <editeng/opaqitem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/adjitem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/sizeitem.hxx> +#include <editeng/svxacorr.hxx> +#include <editeng/scripttypeitem.hxx> +#include <svtools/filter.hxx> +#include <svx/htmlmode.hxx> +#include <svx/pfiledlg.hxx> +#include <svtools/htmlcfg.hxx> +#include <com/sun/star/i18n/TransliterationModules.hdl> + +#include <sot/clsids.hxx> +#include <editeng/acorrcfg.hxx> +#include <wdocsh.hxx> +#include <fmtinfmt.hxx> +#include <fmtclds.hxx> +#include <fmtsrnd.hxx> +#include <fmtfsize.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <docsh.hxx> +#include <doc.hxx> +#include <uitool.hxx> +#include <cmdid.h> +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif +#include <frmmgr.hxx> +#include <textsh.hxx> +#include <frmfmt.hxx> +#include <tablemgr.hxx> +#include <swundo.hxx> // fuer Undo-IDs +#include <shellio.hxx> +#include <frmdlg.hxx> +#include <usrpref.hxx> +#include <swtable.hxx> +#include <tblafmt.hxx> +#include <caption.hxx> +#include <idxmrk.hxx> +#include <poolfmt.hxx> +#include <breakit.hxx> +#include <crsskip.hxx> +#include <modcfg.hxx> +#include <column.hxx> +#include <edtwin.hxx> +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif +#ifndef _POPUP_HRC +#include <popup.hrc> +#endif +#include <swerror.h> +#include <SwAppletImpl.hxx> +#include <unochart.hxx> + +#include <chartins.hxx> + +#define SwTextShell +#define Paragraph +#define HyphenZone +#define TextFont +#define DropCap +#include <sfx2/msg.hxx> +#include <swslots.hxx> +#include <SwRewriter.hxx> +#include <undobj.hxx> +#ifndef _COMCORE_HRC +#include <comcore.hrc> +#endif + +using namespace ::com::sun::star; +using ::rtl::OUString; + +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include "swabstdlg.hxx" +#include <misc.hrc> +#include <table.hrc> +#include <frmui.hrc> +#include <unomid.h> + + + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT)) +{ + SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU)); + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX)); + SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA); + SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD); + SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG); + SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG); + SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG); +} + + + +TYPEINIT1(SwTextShell,SwBaseShell) + + + +void SwTextShell::ExecInsert(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + + ASSERT( !rSh.IsObjSelected() && !rSh.IsFrmSelected(), + "Falsche Shell auf dem Dispatcher" ); + + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + USHORT nSlot = rReq.GetSlot(); + if(pArgs) + pArgs->GetItemState(nSlot, FALSE, &pItem ); + + switch( nSlot ) + { + case FN_INSERT_STRING: + if( pItem ) + rSh.InsertByWord(((const SfxStringItem *)pItem)->GetValue()); + break; + case FN_INSERT_SOFT_HYPHEN: + if( CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( TRUE, 0 ) && + CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( TRUE, -1 )) + rSh.Insert( String( CHAR_SOFTHYPHEN ) ); + break; + + case FN_INSERT_HARDHYPHEN: + case FN_INSERT_HARD_SPACE: + { + sal_Unicode cIns = FN_INSERT_HARD_SPACE == nSlot ? CHAR_HARDBLANK + : CHAR_HARDHYPHEN; + + SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); + SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect(); + if( pACorr && pACfg->IsAutoFmtByInput() && + pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd | + AddNonBrkSpace | ChgOrdinalNumber | + ChgToEnEmDash | SetINetAttr | Autocorrect )) + rSh.AutoCorrect( *pACorr, cIns ); + else + rSh.Insert( String( cIns ) ); + } + break; + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + sal_Unicode cIns = 0; + switch(nSlot) + { + case SID_INSERT_RLM : cIns = CHAR_RLM ; break; + case SID_INSERT_LRM : cIns = CHAR_LRM ; break; + case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; + case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; + } + rSh.Insert( String( cIns ) ); + } + break; + case FN_INSERT_BREAK: + rSh.SplitNode(); + rReq.Done(); + break; + case FN_INSERT_PAGEBREAK: + rSh.InsertPageBreak(); + rReq.Done(); + break; + case FN_INSERT_LINEBREAK: + rSh.InsertLineBreak(); + rReq.Done(); + break; + case FN_INSERT_COLUMN_BREAK: + rSh.InsertColumnBreak(); + rReq.Done(); + break; + case SID_HYPERLINK_SETLINK: + if (pItem) + InsertHyperlink(*((const SvxHyperlinkItem *)pItem)); + rReq.Done(); + break; + case SID_INSERT_AVMEDIA: + rReq.SetReturnValue(SfxBoolItem(nSlot, InsertMediaDlg( rReq ))); + break; + case SID_INSERT_SOUND: + case SID_INSERT_VIDEO: + { + SvxPluginFileDlg aDlg( &GetView().GetViewFrame()->GetWindow(), nSlot ); + aDlg.SetContext( nSlot == SID_INSERT_SOUND? sfx2::FileDialogHelper::SW_INSERT_SOUND : sfx2::FileDialogHelper::SW_INSERT_VIDEO ); + + if ( ERRCODE_NONE == aDlg.Execute() ) + { + // URL ermitteln + String aStrURL( aDlg.GetPath() ); + aStrURL = URIHelper::SmartRel2Abs( + INetURLObject(), aStrURL, URIHelper::GetMaybeFileHdl() ); + + INetURLObject* pURL = new INetURLObject(); + pURL->SetSmartProtocol( INET_PROT_FILE ); + + if ( pURL->SetURL( aStrURL, INetURLObject::WAS_ENCODED ) ) + { + ::rtl::OUString aName; + comphelper::EmbeddedObjectContainer aCnt; + svt::EmbeddedObjectRef xObj( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT ); + if ( xObj.is() ) + { + svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() ); + + // set properties from dialog + uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); + if ( xSet.is() ) + { + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"), + uno::makeAny( ::rtl::OUString( pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) ); + } + } + + rSh.InsertObject( xObj, 0, TRUE, nSlot); + } + } + } + break; + case SID_INSERT_OBJECT: + case SID_INSERT_PLUGIN: + case SID_INSERT_APPLET: + { + SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False ); + SvGlobalName *pName = NULL; + SvGlobalName aName; + if ( pNameItem ) + { + aName = pNameItem->GetValue(); + pName = &aName; + } + + SFX_REQUEST_ARG( rReq, pClassItem, SfxStringItem, FN_PARAM_1, sal_False ); + SFX_REQUEST_ARG( rReq, pClassLocationItem, SfxStringItem, FN_PARAM_2, sal_False ); + SFX_REQUEST_ARG( rReq, pCommandsItem, SfxStringItem, FN_PARAM_3, sal_False ); + //TODO/LATER: recording currently not working, need code for Commandlist + svt::EmbeddedObjectRef xObj; + if((SID_INSERT_APPLET == nSlot || SID_INSERT_PLUGIN) + && (pClassItem || pClassLocationItem || pCommandsItem)) + { + String sClass; + String sClassLocation; + if(pClassItem) + sClass = pClassItem->GetValue(); + if(pClassLocationItem) + sClassLocation = pClassLocationItem->GetValue(); + + SvCommandList aCommandList; + if(pCommandsItem) + { + USHORT nTemp; + aCommandList.AppendCommands( pCommandsItem->GetValue(), &nTemp ); + } + + if(SID_INSERT_APPLET == nSlot) + { + SwApplet_Impl aApplImpl( rSh.GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); + String sBaseURL; + SfxMedium* pMedium = GetView().GetDocShell()->GetMedium(); + if(pMedium) + sBaseURL = pMedium->GetURLObject().GetMainURL(INetURLObject::NO_DECODE); + + aApplImpl.CreateApplet(sClass, aEmptyStr, FALSE, sClassLocation, sBaseURL ); + aApplImpl.FinishApplet(); + xObj.Assign( aApplImpl.GetApplet(), embed::Aspects::MSOLE_CONTENT ); + if( aCommandList.Count() ) + { + uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); + if ( xSet.is() ) + { + uno::Sequence < beans::PropertyValue > aSeq; + aCommandList.FillSequence( aSeq ); + try + { + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands"), uno::makeAny( aSeq ) ); + } + catch ( uno::Exception& ) + { + } + } + } + } + else + { + comphelper::EmbeddedObjectContainer aCnt; + ::rtl::OUString sName; + xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), sName ), + embed::Aspects::MSOLE_CONTENT ); + svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() ); + uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); + if ( xSet.is() ) + { + try + { + if ( sClassLocation.Len() ) + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"), + uno::makeAny( + ::rtl::OUString( + URIHelper::SmartRel2Abs( + INetURLObject(), sClassLocation, + URIHelper::GetMaybeFileHdl()) ) ) ); + uno::Sequence< beans::PropertyValue > aSeq; + if ( aCommandList.Count() ) + { + aCommandList.FillSequence( aSeq ); + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), uno::makeAny( aSeq ) ); + } + } + catch ( uno::Exception& ) + { + } + } + } + + if(xObj.is()) + rSh.InsertOleObject( xObj ); + } + else + { + DBG_ASSERT( !pNameItem || nSlot == SID_INSERT_OBJECT, "Superfluous argument!" ); + rSh.InsertObject( xObj, pName, TRUE, nSlot); + rReq.Done(); + } + break; + } + case SID_INSERT_FLOATINGFRAME: + { + svt::EmbeddedObjectRef xObj; + SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, FN_PARAM_1, sal_False ); + SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, FN_PARAM_2, sal_False ); + SFX_REQUEST_ARG( rReq, pMarginItem, SvxSizeItem, FN_PARAM_3, sal_False ); + SFX_REQUEST_ARG( rReq, pScrollingItem, SfxByteItem, FN_PARAM_4, sal_False ); + SFX_REQUEST_ARG( rReq, pBorderItem, SfxBoolItem, FN_PARAM_5, sal_False ); + + if(pURLItem) // URL is a _must_ + { + comphelper::EmbeddedObjectContainer aCnt; + ::rtl::OUString aName; + xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ), + embed::Aspects::MSOLE_CONTENT ); + svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() ); + uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); + if ( xSet.is() ) + { + try + { + ScrollingMode eScroll = ScrollingAuto; + if( pScrollingItem && pScrollingItem->GetValue() <= ScrollingAuto ) + eScroll = (ScrollingMode) pScrollingItem->GetValue(); + + Size aMargin; + if ( pMarginItem ) + aMargin = pMarginItem->GetSize(); + + if ( pURLItem ) + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), uno::makeAny( ::rtl::OUString( pURLItem->GetValue() ) ) ); + if ( pNameItem ) + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), uno::makeAny( ::rtl::OUString( pNameItem->GetValue() ) ) ); + + if ( eScroll == ScrollingAuto ) + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"), + uno::makeAny( sal_True ) ); + else + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"), + uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) ); + + //if ( aFrmDescr.IsFrameBorderSet() ) + if ( pBorderItem ) + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"), + uno::makeAny( (sal_Bool) pBorderItem->GetValue() ) ); + /*else + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"), + makeAny( sal_True ) );*/ + + if ( pMarginItem ) + { + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"), + uno::makeAny( sal_Int32( aMargin.Width() ) ) ); + + xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"), + uno::makeAny( sal_Int32( aMargin.Height() ) ) ); + } + } + catch ( uno::Exception& ) + { + } + } + + rSh.InsertOleObject( xObj ); + } + else + { + rSh.InsertObject( xObj, 0, TRUE, nSlot); + rReq.Done(); + } + } + break; + case SID_INSERT_DIAGRAM: + { + SvtModuleOptions aMOpt; + if ( !aMOpt.IsChart() ) + break; + if(!rReq.IsAPI()) + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + SwInsertChart( &GetView().GetEditWin(), &pVFrame->GetBindings() ); + } + else + { + uno::Reference< chart2::data::XDataProvider > xDataProvider; + sal_Bool bFillWithData = sal_True; + OUString aRangeString; + if (!GetShell().IsTblComplexForChart()) + { + SwFrmFmt* pTblFmt = GetShell().GetTableFmt(); + String aCurrentTblName = pTblFmt->GetName(); + // String aText( String::CreateFromAscii("<.>") ); // was used for UI + // aText.Insert( rWrtShell.GetBoxNms(), 2); + // aText.Insert( aCurrentTblName, 1 ); + aRangeString = aCurrentTblName; + aRangeString += OUString::valueOf( sal_Unicode('.') ); + aRangeString += GetShell().GetBoxNms(); + + // get table data provider + xDataProvider.set( GetView().GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider() ); + } + else + bFillWithData = sal_False; // will create chart with only it's default image + + SwTableFUNC( &rSh, FALSE ).InsertChart( xDataProvider, bFillWithData, aRangeString ); + rSh.LaunchOLEObj(); + + svt::EmbeddedObjectRef& xObj = rSh.GetOLEObject(); + if(pItem && xObj.is()) + { + Size aSize(((SvxSizeItem*)pItem)->GetSize()); + aSize = OutputDevice::LogicToLogic + ( aSize, MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ) ); + + if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY) + { + awt::Size aSz; + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( xObj.GetViewAspect(), aSz ); + } + } + } + } + break; + + case FN_INSERT_SMA: + { + // #i34343# Inserting a math object into an autocompletion crashes + // the suggestion has to be removed before + GetView().GetEditWin().StopQuickHelp(); + SvGlobalName aGlobalName( SO3_SM_CLASSID ); + rSh.InsertObject( svt::EmbeddedObjectRef(), &aGlobalName, TRUE, 0 ); + } + break; + + case FN_INSERT_TABLE: + InsertTable( rReq ); + break; + + case FN_INSERT_FRAME_INTERACT_NOCOL: + case FN_INSERT_FRAME_INTERACT: + { + USHORT nCols = 1; + BOOL bModifier1 = rReq.GetModifier() == KEY_MOD1; + if(pArgs) + { + if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot && + pArgs->GetItemState(SID_ATTR_COLUMNS, FALSE, &pItem) == SFX_ITEM_SET) + nCols = ((SfxUInt16Item *)pItem)->GetValue(); + if(pArgs->GetItemState(SID_MODIFIER, FALSE, &pItem) == SFX_ITEM_SET) + bModifier1 |= KEY_MOD1 == ((SfxUInt16Item *)pItem)->GetValue(); + } + if(bModifier1 ) + { + SwEditWin& rEdtWin = GetView().GetEditWin(); + Size aWinSize = rEdtWin.GetSizePixel(); + Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2); + aStartPos = rEdtWin.PixelToLogic(aStartPos); + aStartPos.X() -= 8 * MM50; + aStartPos.Y() -= 4 * MM50; + Size aSize(16 * MM50, 8 * MM50); + GetShell().LockPaint(); + GetShell().StartAllAction(); + SwFlyFrmAttrMgr aMgr( TRUE, GetShellPtr(), FRMMGR_TYPE_TEXT ); + if(nCols > 1) + { + SwFmtCol aCol; + aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); + aMgr.SetCol( aCol ); + } + aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize); + GetShell().EndAllAction(); + GetShell().UnlockPaint(); + } + else + { + GetView().InsFrmMode(nCols); + } + rReq.Ignore(); + } + break; + case FN_INSERT_FRAME: + { + BOOL bSingleCol = FALSE; + if( 0!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) ) + { + SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); + USHORT nExport = pHtmlOpt->GetExportMode(); + if( HTML_CFG_MSIE == nExport || + HTML_CFG_HTML32 == nExport || + HTML_CFG_MSIE_40 == nExport || + HTML_CFG_HTML32 == nExport ) + { + bSingleCol = TRUE; + } + + } + // Rahmen neu anlegen + SwFlyFrmAttrMgr aMgr( TRUE, GetShellPtr(), FRMMGR_TYPE_TEXT ); + if(pArgs) + { + Size aSize(aMgr.GetSize()); + aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width(); + Point aPos = aMgr.GetPos(); + RndStdIds eAnchor = FLY_AT_PARA; + if(pArgs->GetItemState(nSlot, FALSE, &pItem) == SFX_ITEM_SET) + eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue(); + if(pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem) == SFX_ITEM_SET) + aPos = ((SfxPointItem *)pItem)->GetValue(); + if(pArgs->GetItemState(FN_PARAM_2, FALSE, &pItem) == SFX_ITEM_SET) + aSize = ((SvxSizeItem *)pItem)->GetSize(); + if(pArgs->GetItemState(SID_ATTR_COLUMNS, FALSE, &pItem) == SFX_ITEM_SET) + { + USHORT nCols = ((SfxUInt16Item *)pItem)->GetValue(); + if( !bSingleCol && 1 < nCols ) + { + SwFmtCol aFmtCol; + aFmtCol.Init( nCols , (rReq.IsAPI() ? 0 + : DEF_GUTTER_WIDTH), USHRT_MAX ); + aMgr.SetCol(aFmtCol); + } + } + + GetShell().LockPaint(); + GetShell().StartAllAction(); + + aMgr.InsertFlyFrm(eAnchor, aPos, aSize); + + GetShell().EndAllAction(); + GetShell().UnlockPaint(); + } + else + { + static USHORT __READONLY_DATA aFrmAttrRange[] = + { + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + FN_GET_PRINT_AREA, FN_GET_PRINT_AREA, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + FN_SET_FRM_NAME, FN_SET_FRM_NAME, + SID_HTML_MODE, SID_HTML_MODE, + 0 + }; + + SfxItemSet aSet(GetPool(), aFrmAttrRange ); + aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell()))); + const SwRect &rPg = GetShell().GetAnyCurRect(RECT_PAGE); + SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height()); + aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE)); + aSet.Put(aFrmSize); + + const SwRect &rPr = GetShell().GetAnyCurRect(RECT_PAGE_PRT); + SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height()); + aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA)); + aSet.Put(aPrtSize); + + aSet.Put(aMgr.GetAttrSet()); + aSet.SetParent( aMgr.GetAttrSet().GetParent() ); + + // Minimalgroesse in Spalten loeschen + SvxBoxInfoItem aBoxInfo((SvxBoxInfoItem &)aSet.Get(SID_ATTR_BORDER_INNER)); + const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX); + aBoxInfo.SetMinDist(FALSE); + aBoxInfo.SetDefDist(rBox.GetDistance(BOX_LINE_LEFT)); + aSet.Put(aBoxInfo); + + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, GetView().GetDocShell())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric))); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD, + GetView().GetViewFrame(), &GetView().GetViewFrame()->GetWindow(), aSet, TRUE); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if(pDlg->Execute() && pDlg->GetOutputItemSet()) + { + GetShell().LockPaint(); + GetShell().StartAllAction(); + GetShell().StartUndo(UNDO_INSERT); + + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + aMgr.SetAttrSet(*pOutSet); + + // beim ClickToEditFeld erst die Selektion loeschen + if( GetShell().IsInClickToEdit() ) + GetShell().DelRight(); + + aMgr.InsertFlyFrm(); + + uno::Reference< frame::XDispatchRecorder > xRecorder = + GetView().GetViewFrame()->GetBindings().GetRecorder(); + if ( xRecorder.is() ) + { + //FN_INSERT_FRAME + USHORT nAnchor = (USHORT)aMgr.GetAnchor(); + rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor)); + rReq.AppendItem(SfxPointItem(FN_PARAM_1, GetShell().GetObjAbsPos())); + rReq.AppendItem(SvxSizeItem(FN_PARAM_2, GetShell().GetObjSize())); + rReq.Done(); + } + + GetView().AutoCaption(FRAME_CAP); + + { + SwRewriter aRewriter; + + aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_FRAME)); + + GetShell().EndUndo(UNDO_INSERT, &aRewriter); + } + GetShell().EndAllAction(); + GetShell().UnlockPaint(); + } + + DELETEZ(pDlg); + } + break; + } + case FN_INSERT_HRULER: + { + String sPath; + BOOL bSimpleLine = FALSE; + BOOL bRet = FALSE; + Window* pParent = GetView().GetWindow(); + if ( pItem ) + { + sPath = ((SfxStringItem*)pItem)->GetValue(); + SFX_REQUEST_ARG( rReq, pSimple, SfxBoolItem, FN_PARAM_1 , sal_False ); + if ( pSimple ) + bSimpleLine = pSimple->GetValue(); + } + else + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractInsertGrfRulerDlg* pDlg = pFact->CreateInsertGrfRulerDlg( DLG_INSERT_RULER, + pParent ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + // MessageBox fuer fehlende Grafiken + if(!pDlg->HasImages()) + InfoBox( pParent, SW_RES(MSG_NO_RULER)).Execute(); + if(RET_OK == pDlg->Execute()) + { + sPath = pDlg->GetGraphicName(); + bSimpleLine = pDlg->IsSimpleLine(); + } + + delete pDlg; + rReq.AppendItem( SfxStringItem( FN_INSERT_HRULER, sPath ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bSimpleLine ) ); + } + + rSh.StartAllAction(); + rSh.StartUndo(UNDO_UI_INSERT_RULER); + if(bSimpleLine) + { + if(!(rSh.IsSttOfPara() && rSh.IsEndOfPara())) // kein leerer Absatz? + rSh.SplitNode( FALSE, FALSE ); // dann Platz schaffen + rSh.SplitNode( FALSE, FALSE ); + rSh.Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); + rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_HTML_HR )); + rSh.Right(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); + bRet = TRUE; + } + else if(sPath.Len()) + { + SwFlyFrmAttrMgr aFrmMgr( TRUE, &rSh, FRMMGR_TYPE_GRF ); + // am FrmMgr muessen die richtigen Parameter eingestellt werden + + aFrmMgr.SetAnchor(FLY_AS_CHAR); + + rSh.SplitNode( FALSE, FALSE ); + rSh.SplitNode( FALSE, FALSE ); + rSh.Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); + rSh.SetAttr(SvxAdjustItem(SVX_ADJUST_CENTER,RES_PARATR_ADJUST )); + if(GRFILTER_OK == GetView().InsertGraphic(sPath, aEmptyStr, TRUE, 0, 0 )) + bRet = TRUE; + rSh.EnterStdMode(); + rSh.Right(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); + } + rSh.EndAllAction(); + rSh.EndUndo(UNDO_UI_INSERT_RULER); + rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); + rReq.Done(); + } + break; + case FN_FORMAT_COLUMN : + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + VclAbstractDialog* pColDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN); + DBG_ASSERT(pColDlg, "Dialogdiet fail!"); + pColDlg->Execute(); + delete pColDlg; + } + break; + + default: + ASSERT( !this, "falscher Dispatcher" ); + return; + } +} + +bool lcl_IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect ) +{ + rWrtSh.SwapPam(); + bool bRet = pSect == rWrtSh.GetCurrSection(); + rWrtSh.SwapPam(); + return bRet; +} + + +void SwTextShell::StateInsert( SfxItemSet &rSet ) +{ + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + SfxWhichIter aIter( rSet ); + SwWrtShell &rSh = GetShell(); + USHORT nWhich = aIter.FirstWhich(); + SvtModuleOptions aMOpt; + SfxObjectCreateMode eCreateMode = + GetView().GetDocShell()->GetCreateMode(); + + rSh.Push(); + const BOOL bCrsrInHidden = rSh.SelectHiddenRange(); + // --> OD 2009-08-05 #i103839#, #b6855246# + // Do not call method <SwCrsrShell::Pop(..)> with 1st parameter = <FALSE> + // in order to avoid that the view jumps to the visible cursor. + rSh.Pop(); + // <-- + + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_INSERT_SOUND: + case SID_INSERT_VIDEO: + /*!SvxPluginFileDlg::IsAvailable( nWhich ) || + + discussed with mba: for performance reasons we skip the IsAvailable call here + */ + if ( GetShell().IsSelFrmMode() || + SFX_CREATE_MODE_EMBEDDED == eCreateMode || bCrsrInHidden ) + { + rSet.DisableItem( nWhich ); + } + break; + + case SID_INSERT_DIAGRAM: + if( !aMOpt.IsChart() || eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden ) + { + rSet.DisableItem( nWhich ); + } + break; + + case FN_INSERT_SMA: + if( !aMOpt.IsMath() || eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden ) + { + rSet.DisableItem( nWhich ); + } + break; + + case SID_INSERT_FLOATINGFRAME: + case SID_INSERT_OBJECT: + case SID_INSERT_PLUGIN: + case SID_INSERT_APPLET: + { + if( +#ifndef SOLAR_JAVA + nWhich == SID_INSERT_APPLET || +#endif + eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden ) + { + rSet.DisableItem( nWhich ); + } + else if( GetShell().IsSelFrmMode()) + rSet.DisableItem( nWhich ); + else if(SID_INSERT_FLOATINGFRAME == nWhich && nHtmlMode&HTMLMODE_ON) + { + SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); + USHORT nExport = pHtmlOpt->GetExportMode(); + if(HTML_CFG_MSIE_40 != nExport && HTML_CFG_WRITER != nExport ) + rSet.DisableItem(nWhich); + } + } + break; + case FN_INSERT_FRAME_INTERACT_NOCOL : + case FN_INSERT_FRAME_INTERACT: + { + if ( GetShell().IsSelFrmMode() || + (0 != (nHtmlMode & HTMLMODE_ON) && 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)) || bCrsrInHidden ) + rSet.DisableItem(nWhich); + } + break; + case SID_HYPERLINK_GETLINK: + { + SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); + rSh.GetCurAttr( aSet ); + + SvxHyperlinkItem aHLinkItem; + const SfxPoolItem* pItem; + if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, FALSE, &pItem)) + { + const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem; + aHLinkItem.SetURL(pINetFmt->GetValue()); + aHLinkItem.SetTargetFrame(pINetFmt->GetTargetFrame()); + aHLinkItem.SetIntName(pINetFmt->GetName()); + const SvxMacro *pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT ); + if( pMacro ) + aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro); + + pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT ); + if( pMacro ) + aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro); + + pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT ); + if( pMacro ) + aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro); + + // Text des Links besorgen + rSh.StartAction(); + rSh.CreateCrsr(); + rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT,TRUE); + String sLinkName = rSh.GetSelTxt(); + aHLinkItem.SetName(sLinkName); + aHLinkItem.SetInsertMode(HLINK_FIELD); + rSh.DestroyCrsr(); + rSh.EndAction(); + } + else + { + String sReturn = rSh.GetSelTxt(); + sReturn.Erase(255); + sReturn.EraseTrailingChars(); + aHLinkItem.SetName(sReturn); + } + + aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | + ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); + aHLinkItem.SetMacroEvents ( HYPERDLG_EVENT_MOUSEOVER_OBJECT| + HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT ); + + rSet.Put(aHLinkItem); + } + break; + + case FN_INSERT_FRAME: + if(rSh.IsSelFrmMode()) + { + const int nSel = rSh.GetSelectionType(); + if( ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE ) & nSel ) || bCrsrInHidden ) + rSet.DisableItem(nWhich); + } + break; + case FN_INSERT_HRULER : + if(rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() || bCrsrInHidden ) + rSet.DisableItem(nWhich); + break; + case FN_FORMAT_COLUMN : + { + //#i80458# column dialog cannot work if the selection contains different page styles and different sections + bool bDisable = true; + if( rSh.GetFlyFrmFmt() || rSh.GetSelectedPageDescs() ) + bDisable = false; + if( bDisable ) + { + const SwSection* pCurrSection = rSh.GetCurrSection(); + USHORT nFullSectCnt = rSh.GetFullSelectedSectionCount(); + if( pCurrSection && ( !rSh.HasSelection() || 0 != nFullSectCnt )) + bDisable = false; + else if( + rSh.HasSelection() && rSh.IsInsRegionAvailable() && + ( !pCurrSection || ( 1 != nFullSectCnt && + lcl_IsMarkInSameSection( rSh, pCurrSection ) ))) + bDisable = false; + } + if(bDisable) + rSet.DisableItem(nWhich); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwTextShell::ExecDelete(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + switch( rReq.GetSlot() ) + { + case FN_DELETE_SENT: + if( rSh.IsTableMode() ) + { + rSh.DeleteRow(); + rSh.EnterStdMode(); + } + else + rSh.DelToEndOfSentence(); + break; + case FN_DELETE_BACK_SENT: + rSh.DelToStartOfSentence(); + break; + case FN_DELETE_WORD: + rSh.DelNxtWord(); + break; + case FN_DELETE_BACK_WORD: + rSh.DelPrvWord(); + break; + case FN_DELETE_LINE: + rSh.DelToEndOfLine(); + break; + case FN_DELETE_BACK_LINE: + rSh.DelToStartOfLine(); + break; + case FN_DELETE_PARA: + rSh.DelToEndOfPara(); + break; + case FN_DELETE_BACK_PARA: + rSh.DelToStartOfPara(); + break; + case FN_DELETE_WHOLE_LINE: + rSh.DelLine(); + break; + default: + ASSERT(!this, "falscher Dispatcher"); + return; + } + rReq.Done(); +} + +void SwTextShell::ExecTransliteration( SfxRequest & rReq ) +{ + using namespace ::com::sun::star::i18n; + { + sal_uInt32 nMode = 0; + + switch( rReq.GetSlot() ) + { + case SID_TRANSLITERATE_UPPER: + nMode = TransliterationModules_LOWERCASE_UPPERCASE; + break; + case SID_TRANSLITERATE_LOWER: + nMode = TransliterationModules_UPPERCASE_LOWERCASE; + break; + + case SID_TRANSLITERATE_HALFWIDTH: + nMode = TransliterationModules_FULLWIDTH_HALFWIDTH; + break; + case SID_TRANSLITERATE_FULLWIDTH: + nMode = TransliterationModules_HALFWIDTH_FULLWIDTH; + break; + + case SID_TRANSLITERATE_HIRAGANA: + nMode = TransliterationModules_KATAKANA_HIRAGANA; + break; + case SID_TRANSLITERATE_KATAGANA: + nMode = TransliterationModules_HIRAGANA_KATAKANA; + break; + + default: + ASSERT(!this, "falscher Dispatcher"); + } + + if( nMode ) + GetShell().TransliterateText( nMode ); + } +} + + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + + +SwTextShell::SwTextShell(SwView &_rView) : + SwBaseShell(_rView), pPostItFldMgr( 0 ) +{ + SetName(String::CreateFromAscii("Text")); + SetHelpId(SW_TEXTSHELL); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +SwTextShell::~SwTextShell() +{ +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwTextShell::InsertSymbol( SfxRequest& rReq ) +{ + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + if( pArgs ) + pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem); + + String aChars, aFontName; + if ( pItem ) + { + aChars = ((const SfxStringItem*)pItem)->GetValue(); + const SfxPoolItem* pFtItem = NULL; + pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem); + const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); + if ( pFontItem ) + aFontName = pFontItem->GetValue(); + } + + SwWrtShell &rSh = GetShell(); + SfxItemSet aSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT, + RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, + RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, + 0 ); + rSh.GetCurAttr( aSet ); + USHORT nScript = rSh.GetScriptType(); + + SvxFontItem aFont( RES_CHRATR_FONT ); + { + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); + aSetItem.GetItemSet().Put( aSet, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); + if( pI ) + aFont = *(SvxFontItem*)pI; + else + aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( + RES_CHRATR_FONT, + GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) )); + if (!aFontName.Len()) + aFontName = aFont.GetFamilyName(); + } + + Font aNewFont(aFontName, Size(1,1)); // Size nur wg. CTOR + if( !aChars.Len() ) + { + // Eingestellten Font als Default + SfxAllItemSet aAllSet( rSh.GetAttrPool() ); + aAllSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) ); + + SwViewOption aOpt(*GetShell().GetViewOptions()); + String sSymbolFont = aOpt.GetSymbolFont(); + if( !aFontName.Len() && sSymbolFont.Len() ) + aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); + else + aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet, + GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); + if( RET_OK == pDlg->Execute() ) + { + SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, FALSE ); + SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE ); + if ( pFontItem ) + { + aNewFont.SetName( pFontItem->GetFamilyName() ); + aNewFont.SetStyleName( pFontItem->GetStyleName() ); + aNewFont.SetCharSet( pFontItem->GetCharSet() ); + aNewFont.SetPitch( pFontItem->GetPitch() ); + } + + if ( pCItem ) + { + aChars = pCItem->GetValue(); + aOpt.SetSymbolFont(aNewFont.GetName()); + SW_MOD()->ApplyUsrPref(aOpt, &GetView()); + } + } + + delete pDlg; + } + + BOOL bFontChanged = FALSE; + if( aChars.Len() ) + { + rSh.StartAllAction(); + + // Selektierten Inhalt loeschen + SwRewriter aRewriter; + aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_SPECIALCHAR)); + + rSh.StartUndo( UNDO_INSERT, &aRewriter ); + if ( rSh.HasSelection() ) + { + rSh.DelRight(); + aSet.ClearItem(); + rSh.GetCurAttr( aSet ); + + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); + aSetItem.GetItemSet().Put( aSet, FALSE ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); + if( pI ) + aFont = *(SvxFontItem*)pI; + else + aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( + RES_CHRATR_FONT, + GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) )); + } + + // Zeichen einfuegen + rSh.Insert( aChars ); + + // #108876# a font attribute has to be set always due to a guessed script type + if( aNewFont.GetName().Len() ) + { + bFontChanged = TRUE; + SvxFontItem aNewFontItem( aFont ); + aNewFontItem.GetFamilyName() = aNewFont.GetName(); + aNewFontItem.GetFamily() = aNewFont.GetFamily(); + aNewFontItem.GetPitch() = aNewFont.GetPitch(); + aNewFontItem.GetCharSet() = aNewFont.GetCharSet(); + + SfxItemSet aRestoreSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT, + RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, + RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 0 ); + + nScript = pBreakIt->GetAllScriptsOfText( aChars ); + if( SCRIPTTYPE_LATIN & nScript ) + { + aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT, TRUE ) ); + aSet.Put( aNewFontItem, RES_CHRATR_FONT); + } + if( SCRIPTTYPE_ASIAN & nScript ) + { + aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT, TRUE ) ); + aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT ); + } + if( SCRIPTTYPE_COMPLEX & nScript ) + { + aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT, TRUE ) ); + aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT ); + } + + rSh.SetMark(); + rSh.ExtendSelection( FALSE, aChars.Len() ); + rSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND | nsSetAttrMode::SETATTR_NOFORMATATTR ); + if( !rSh.IsCrsrPtAtEnd() ) + rSh.SwapPam(); + + rSh.ClearMark(); + + // --> FME 2007-07-09 #i75891# + // SETATTR_DONTEXPAND does not work if there are already hard attributes. + // Therefore we have to restore the font attributes. + rSh.SetMark(); + rSh.SetAttr( aRestoreSet ); + rSh.ClearMark(); + // <-- + + rSh.UpdateAttr(); + aFont = aNewFontItem; + } + + rSh.EndAllAction(); + rSh.EndUndo( UNDO_INSERT ); + + if ( aChars.Len() ) + { + rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) ); + rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetName() ) ); + rReq.Done(); + } + } +} + + diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx new file mode 100644 index 000000000000..b7aa72acfb2c --- /dev/null +++ b/sw/source/ui/shells/textsh1.cxx @@ -0,0 +1,1735 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <comphelper/processfactory.hxx> +#include <svx/dialogs.hrc> +#include <hintids.hxx> +#include <cmdid.h> +#include <helpid.h> + +#include <i18npool/mslangid.hxx> +#include <svl/languageoptions.hxx> +#include <editeng/langitem.hxx> +#include <svtools/langtab.hxx> +#include <svl/slstitm.hxx> +#include <string.h> +#include <svl/stritem.hxx> +#include <svx/htmlmode.hxx> +#include <svl/whiter.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objitem.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/unohelp2.hxx> +#include <sfx2/request.hxx> +#include <svl/eitem.hxx> +#include <svl/macitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/tstpitem.hxx> +#include <editeng/brshitem.hxx> +#include <editeng/svxacorr.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> +#include <IDocumentSettingAccess.hxx> +#include <charfmt.hxx> +#include <editeng/fontitem.hxx> +#include <svx/SmartTagItem.hxx> +#include <svx/dialmgr.hxx> +#include <fmtinfmt.hxx> +#include <swwait.hxx> +#include <wrtsh.hxx> +#include <wview.hxx> +#include <swmodule.hxx> +#include <viewopt.hxx> +#include <uitool.hxx> +#include <swevent.hxx> +#include <fmthdft.hxx> +#include <pagedesc.hxx> +#include <textsh.hxx> +#include <IMark.hxx> +#include <swdtflvr.hxx> +#include <docstat.hxx> +#include <outline.hxx> +#include <tablemgr.hxx> +#include <swundo.hxx> // fuer Undo-IDs +#include <reffld.hxx> +#include <docsh.hxx> +#include <mdiexp.hxx> +#include <inputwin.hxx> +#include <pardlg.hxx> +#include <frmatr.hxx> +#include <fmtcol.hxx> +#include <cellatr.hxx> +#include <edtwin.hxx> +#include <redlndlg.hxx> +#include "fldmgr.hxx" + +#include <globals.hrc> +#include <shells.hrc> +#include <app.hrc> +#include <web.hrc> +#include "paratr.hxx" +#include <crsskip.hxx> +#include <docstat.hxx> +#include <vcl/svapp.hxx> +#include <sfx2/app.hxx> +#include <breakit.hxx> + +#include <SwSmartTagMgr.hxx> + +#include <editeng/acorrcfg.hxx> +#include "swabstdlg.hxx" +#include "misc.hrc" +#include "chrdlg.hrc" +#include <IDocumentStatistics.hxx> + +#include <sfx2/sfxdlg.hxx> +#include <svl/languageoptions.hxx> +#include <unotools/lingucfg.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XChangesBatch.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <editeng/unolingu.hxx> +#include <unotools/syslocaleoptions.hxx> +#include <doc.hxx> +#include <view.hxx> +#include <ndtxt.hxx> +#include <pam.hxx> + +#include <langhelper.hxx> + +using namespace ::com::sun::star; + + +void lcl_CharDialog( SwWrtShell &rWrtSh, BOOL bUseDialog, USHORT nSlot,const SfxItemSet *pArgs, SfxRequest *pReq ) +{ + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rWrtSh.GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric))); + SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END-1, + RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, + RES_BACKGROUND, RES_BACKGROUND, + FN_PARAM_SELECTION, FN_PARAM_SELECTION, + SID_HTML_MODE, SID_HTML_MODE, + SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, + 0 ); + rWrtSh.GetCurAttr( aCoreSet ); + BOOL bSel = rWrtSh.HasSelection(); + BOOL bSelectionPut = FALSE; + if(bSel || rWrtSh.IsInWord()) + { + if(!bSel) + { + rWrtSh.StartAction(); + rWrtSh.Push(); + if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT )) + rWrtSh.SelWrd(); + } + aCoreSet.Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelTxt())); + bSelectionPut = TRUE; + if(!bSel) + { + rWrtSh.Pop(FALSE); + rWrtSh.EndAction(); + } + } + aCoreSet.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, + rWrtSh.GetScalingOfSelectedText() ) ); + // Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in + // ein RES_BACKGROUND verwandelt und wieder zurueck ... + const SfxPoolItem *pTmpBrush; + if( SFX_ITEM_SET == aCoreSet.GetItemState( RES_CHRATR_BACKGROUND, TRUE, &pTmpBrush ) ) + { + SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); + aTmpBrush.SetWhich( RES_BACKGROUND ); + aCoreSet.Put( aTmpBrush ); + } + + aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell()))); + SfxAbstractTabDialog* pDlg = NULL; + if ( bUseDialog && GetActiveView() ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + pDlg = pFact->CreateSwCharDlg( rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, DLG_CHAR ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if( FN_INSERT_HYPERLINK == nSlot ) + pDlg->SetCurPageId(TP_CHAR_URL); + } + + const SfxItemSet* pSet = NULL; + if ( !bUseDialog ) + pSet = pArgs; + else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */ + { + pSet = pDlg->GetOutputItemSet(); + } + + if ( pSet) + { + SfxItemSet aTmpSet( *pSet ); + if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND, FALSE, &pTmpBrush ) ) + { + SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); + aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); + aTmpSet.Put( aTmpBrush ); + } + + aTmpSet.ClearItem( RES_BACKGROUND ); + + const SfxPoolItem* pSelectionItem; + BOOL bInsert = FALSE; + xub_StrLen nInsert = 0; + + // aus ungeklaerter Ursache ist das alte Item wieder im Set + if( !bSelectionPut && SFX_ITEM_SET == aTmpSet.GetItemState(FN_PARAM_SELECTION, FALSE, &pSelectionItem) ) + { + String sInsert = ((const SfxStringItem*)pSelectionItem)->GetValue(); + bInsert = sInsert.Len() != 0; + if(bInsert) + { + nInsert = sInsert.Len(); + rWrtSh.StartAction(); + rWrtSh.Insert( sInsert ); + rWrtSh.SetMark(); + rWrtSh.ExtendSelection(FALSE, sInsert.Len()); + SfxRequest aReq( rWrtSh.GetView().GetViewFrame(), FN_INSERT_STRING ); + aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sInsert ) ); + aReq.Done(); + SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_LEFT ); + aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) ); + aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, TRUE) ); + aReq1.Done(); + } + } + aTmpSet.ClearItem(FN_PARAM_SELECTION); + + SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); + if(bSel && rWrtSh.IsSelFullPara() && pColl && pColl->IsAutoUpdateFmt()) + { + rWrtSh.AutoUpdatePara(pColl, aTmpSet); + } + else + rWrtSh.SetAttr( aTmpSet ); + if (pReq) + pReq->Done(aTmpSet); + if(bInsert) + { + SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_RIGHT ); + aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) ); + aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, FALSE) ); + aReq1.Done(); + rWrtSh.SwapPam(); + rWrtSh.ClearMark(); + rWrtSh.DontExpandFmt(); + rWrtSh.EndAction(); + } + } + + delete pDlg; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +short lcl_AskRedlineMode(Window *pWin) +{ + MessBox aQBox( pWin, 0, + String( SW_RES( STR_REDLINE_TITLE ) ), + String( SW_RES( STR_REDLINE_MSG ) ) ); + aQBox.SetImage( QueryBox::GetStandardImage() ); + USHORT nBtnFlags = BUTTONDIALOG_DEFBUTTON | + BUTTONDIALOG_OKBUTTON | + BUTTONDIALOG_FOCUSBUTTON; + + aQBox.AddButton(String(SW_RES(STR_REDLINE_ACCEPT_ALL)), RET_OK, nBtnFlags); + aQBox.GetPushButton( RET_OK )->SetHelpId(HID_AUTOFORMAT_ACCEPT); + aQBox.AddButton(String(SW_RES(STR_REDLINE_REJECT_ALL)), RET_CANCEL, BUTTONDIALOG_CANCELBUTTON); + aQBox.GetPushButton( RET_CANCEL )->SetHelpId(HID_AUTOFORMAT_REJECT ); + aQBox.AddButton(String(SW_RES(STR_REDLINE_EDIT)), 2, 0); + aQBox.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG); + aQBox.SetButtonHelpText( RET_OK, aEmptyStr ); + + return aQBox.Execute(); +} + +void SwTextShell::Execute(SfxRequest &rReq) +{ + BOOL bUseDialog = TRUE; + const SfxItemSet *pArgs = rReq.GetArgs(); + SwWrtShell& rWrtSh = GetShell(); + const SfxPoolItem* pItem = 0; + USHORT nSlot = rReq.GetSlot(); + if(pArgs) + pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem); + switch( nSlot ) + { + case SID_LANGUAGE_STATUS: + { + // get the language + String aNewLangTxt; + SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , sal_False ); + if (pItem2) + aNewLangTxt = pItem2->GetValue(); + + //!! Remember the view frame right now... + //!! (call to GetView().GetViewFrame() will break if the + //!! SwTextShell got destroyed meanwhile.) + SfxViewFrame *pViewFrame = GetView().GetViewFrame(); + + if (aNewLangTxt.EqualsAscii( "*" )) + { + // open the dialog "Tools/Options/Language Settings - Language" + // to set the documents default language + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + if (pFact) + { + VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); + pDlg->Execute(); + delete pDlg; + } + } + else + { + //!! We have to use StartAction / EndAction bracketing in + //!! order to prevent possible destruction of the SwTextShell + //!! due to the selection changes coming below. + rWrtSh.StartAction(); + // prevent view from jumping because of (temporary) selection changes + rWrtSh.LockView( TRUE ); + // save selection for later restoration + rWrtSh.Push(); + + // setting the new language... + if (aNewLangTxt.Len() > 0) + { + const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); + const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); + const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); + const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); + + SfxItemSet aCoreSet( GetPool(), + RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, + RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, + RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, + 0 ); + + xub_StrLen nPos = 0; + bool bForSelection = true; + bool bForParagraph = false; + if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) + { + // ... for the current selection + aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); + bForSelection = true; + } + else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) + { + // ... for the current paragraph language + aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); + bForSelection = true; + bForParagraph = true; + } + else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) + { + // ... as default document language + aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); + bForSelection = false; + } + + if (bForParagraph) + SwLangHelper::SelectCurrentPara( rWrtSh ); + + if (!bForSelection) // document language to be changed... + { + rWrtSh.SelAll(); + rWrtSh.ExtendedSelectAll(); + } + if (aNewLangTxt != aStrNone) + SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet ); + else + SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet ); + } + + // restore selection... + rWrtSh.Pop( FALSE ); + + rWrtSh.LockView( FALSE ); + rWrtSh.EndAction(); + } + + // invalidate slot to get the new language displayed + pViewFrame->GetBindings().Invalidate( nSlot ); + + rReq.Done(); + break; + } + + case SID_CHARMAP: + { + InsertSymbol( rReq ); + } + break; + case FN_INSERT_FOOTNOTE: + case FN_INSERT_ENDNOTE: + { + String aStr; + SFX_REQUEST_ARG( rReq, pFont, SfxStringItem, FN_PARAM_1 , sal_False ); +// SFX_REQUEST_ARG( rReq, pCharset, SfxInt16Item, FN_PARAM_2 , sal_False ); + SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, nSlot , sal_False ); + if ( pNameItem ) + aStr = pNameItem->GetValue(); + BOOL bFont = pFont && pFont->GetValue().Len(); + rWrtSh.StartUndo( UNDO_UI_INSERT_FOOTNOTE ); + rWrtSh.InsertFootnote( aStr, nSlot == FN_INSERT_ENDNOTE, !bFont ); + if ( bFont ) + { + rWrtSh.Left( CRSR_SKIP_CHARS, TRUE, 1, FALSE ); + SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT ); + rWrtSh.GetCurAttr( aSet ); + SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT ); + SvxFontItem aFont( rFont.GetFamily(), pFont->GetValue(), + rFont.GetStyleName(), rFont.GetPitch(), RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT ); + //pCharset ? (CharSet) pCharset->GetValue() : RTL_TEXTENCODING_DONTKNOW ); + rWrtSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND ); + rWrtSh.ResetSelect(0, FALSE); + rWrtSh.EndSelect(); + rWrtSh.GotoFtnTxt(); + } + rWrtSh.EndUndo( UNDO_UI_INSERT_FOOTNOTE ); + rReq.Done(); + } + break; + case FN_INSERT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE, + GetView().GetWindow(), rWrtSh, FALSE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->SetHelpId(nSlot); + if ( pDlg->Execute() == RET_OK ) + { + USHORT nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE; + SfxRequest aReq( GetView().GetViewFrame(), nId ); + if ( pDlg->GetStr().Len() ) + aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) ); + if ( pDlg->GetFontName().Len() ) + aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) ); + //aReq.AppendItem( SfxStringItem( FN_PARAM_2, pDlg->GetCharSet() ) ); + ExecuteSlot( aReq ); + } + + rReq.Ignore(); + delete pDlg; + } + break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rWrtSh, DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case SID_INSERTDOC: + { + GetView().ExecuteInsertDoc( rReq, pItem ); + break; + } + case FN_FORMAT_RESET: + { + // #i78856, reset all attributes but not the language attributes + // (for this build an array of all relevant attributes and + // remove the languages from that) + SvUShortsSort aAttribs; + + USHORT __FAR_DATA aResetableSetRange[] = { + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_CHRATR_BEGIN, RES_CHRATR_LANGUAGE - 1, + RES_CHRATR_LANGUAGE + 1, RES_CHRATR_CJK_LANGUAGE - 1, + RES_CHRATR_CJK_LANGUAGE + 1, RES_CHRATR_CTL_LANGUAGE - 1, + RES_CHRATR_CTL_LANGUAGE + 1, RES_CHRATR_END-1, + RES_PARATR_BEGIN, RES_PARATR_END-1, + RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, + RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, + 0 + }; + USHORT __FAR_DATA *pUShorts = aResetableSetRange; + while (*pUShorts) + { + USHORT nL = pUShorts[1] - pUShorts[0] + 1; + USHORT nE = pUShorts[0]; + for (USHORT i = 0; i < nL; ++i) + aAttribs.Insert( nE++ ); + pUShorts += 2; + } + + rWrtSh.ResetAttr( &aAttribs ); + rReq.Done(); + break; + } + case FN_INSERT_BREAK_DLG: + { + USHORT nKind=0, nPageNumber=0; + String aTemplateName; + if ( pItem ) + { + nKind = ((SfxInt16Item*)pItem)->GetValue(); + SFX_REQUEST_ARG( rReq, pTemplate, SfxStringItem, FN_PARAM_1 , sal_False ); + SFX_REQUEST_ARG( rReq, pNumber, SfxUInt16Item, FN_PARAM_2 , sal_False ); + if ( pTemplate ) + aTemplateName = pTemplate->GetValue(); + if ( pNumber ) + nPageNumber = pNumber->GetValue(); + } + else + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSwBreakDlg* pDlg = pFact->CreateSwBreakDlg( GetView().GetWindow(), rWrtSh, DLG_BREAK ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( pDlg->Execute() == RET_OK ) + { + nKind = pDlg->GetKind(); + aTemplateName = pDlg->GetTemplateName(); + nPageNumber = pDlg->GetPageNumber(); + rReq.AppendItem( SfxInt16Item( FN_INSERT_BREAK_DLG, nKind ) ); + rReq.AppendItem( SfxUInt16Item( FN_PARAM_2, nPageNumber ) ); + rReq.AppendItem( SfxStringItem( FN_PARAM_1, aTemplateName ) ); + rReq.Done(); + } + else + rReq.Ignore(); + delete pDlg; + } + + switch ( nKind ) + { + case 1 : + rWrtSh.InsertLineBreak(); break; + case 2 : + rWrtSh.InsertColumnBreak(); break; + case 3 : + { + rWrtSh.StartAllAction(); + if( aTemplateName.Len() ) + rWrtSh.InsertPageBreak( &aTemplateName, nPageNumber ); + else + rWrtSh.InsertPageBreak(); + rWrtSh.EndAllAction(); + } + } + + break; + } + case FN_INSERT_BOOKMARK: + { + if ( pItem ) + { + ::rtl::OUString sName = ((SfxStringItem*)pItem)->GetValue(); + rWrtSh.SetBookmark( KeyCode(), sName, aEmptyStr ); + } + else + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + } + + break; + } + case FN_DELETE_BOOKMARK: + { + if ( pItem ) + { + IDocumentMarkAccess* const pMarkAccess = rWrtSh.getIDocumentMarkAccess(); + pMarkAccess->deleteMark( pMarkAccess->findMark(((SfxStringItem*)pItem)->GetValue()) ); + } + break; + } + case FN_AUTOFORMAT_REDLINE_APPLY: + { + SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags()); + // das muss fuer die Nachbearbeitung immer FALSE sein + aFlags.bAFmtByInput = FALSE; + aFlags.bWithRedlining = TRUE; + rWrtSh.AutoFormat( &aFlags ); + aFlags.bWithRedlining = FALSE; + + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pVFrame->HasChildWindow(FN_REDLINE_ACCEPT)) + pVFrame->ToggleChildWindow(FN_REDLINE_ACCEPT); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSwModalRedlineAcceptDlg* pDlg = pFact->CreateSwModalRedlineAcceptDlg( &GetView().GetEditWin(), DLG_MOD_REDLINE_ACCEPT ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + + switch (lcl_AskRedlineMode(&GetView().GetEditWin())) + { + case RET_OK: + { + pDlg->AcceptAll(TRUE); + SfxRequest aReq( pVFrame, FN_AUTOFORMAT_APPLY ); + aReq.Done(); + rReq.Ignore(); + break; + } + + case RET_CANCEL: + pDlg->AcceptAll(FALSE); + rReq.Ignore(); + break; + + case 2: + pDlg->Execute(); + rReq.Done(); + break; + } + delete pDlg; + } + break; + + case FN_AUTOFORMAT_APPLY: + { + SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags()); + // das muss fuer die Nachbearbeitung immer FALSE sein + aFlags.bAFmtByInput = FALSE; + rWrtSh.AutoFormat( &aFlags ); + rReq.Done(); + } + break; + case FN_AUTOFORMAT_AUTO: + { + SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); + BOOL bSet = pItem ? ((const SfxBoolItem*)pItem)->GetValue() : !pACfg->IsAutoFmtByInput(); + if( bSet != pACfg->IsAutoFmtByInput() ) + { + pACfg->SetAutoFmtByInput( bSet ); + GetView().GetViewFrame()->GetBindings().Invalidate( nSlot ); + if ( !pItem ) + rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), bSet ) ); + rReq.Done(); + } + } + break; + case FN_AUTO_CORRECT: + { + // erstmal auf Blank defaulten + sal_Unicode cChar = ' '; + rWrtSh.AutoCorrect( *SvxAutoCorrCfg::Get()->GetAutoCorrect(), cChar ); + rReq.Done(); + } + break; + case FN_TABLE_SORT_DIALOG: + case FN_SORTING_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, rWrtSh); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case FN_CALCULATE: + { + SwTransferable* pTransfer = new SwTransferable( rWrtSh ); +/*??*/ uno::Reference< + datatransfer::XTransferable > xRef( + pTransfer ); + pTransfer->CalculateAndCopy(); + rReq.Done(); + } + break; + case FN_GOTO_REFERENCE: + { + SwField *pFld = rWrtSh.GetCurFld(); + if(pFld && pFld->GetTypeId() == TYP_GETREFFLD) + { + rWrtSh.StartAllAction(); + rWrtSh.SwCrsrShell::GotoRefMark( ((SwGetRefField*)pFld)->GetSetRefName(), + ((SwGetRefField*)pFld)->GetSubType(), + ((SwGetRefField*)pFld)->GetSeqNo() ); + rWrtSh.EndAllAction(); + rReq.Done(); + } + } + break; + case FN_EDIT_FORMULA: + { + const USHORT nId = SwInputChild::GetChildWindowId(); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if(pItem) + { + //if the ChildWindow is active it has to be removed + if( pVFrame->HasChildWindow( nId ) ) + { + pVFrame->ToggleChildWindow( nId ); + pVFrame->GetBindings().InvalidateAll( TRUE ); + } + + String sFormula(((const SfxStringItem*)pItem)->GetValue()); + SwFldMgr aFldMgr; + rWrtSh.StartAllAction(); + BOOL bDelSel; + if( 0 != (bDelSel = rWrtSh.HasSelection()) ) + { + rWrtSh.StartUndo( UNDO_START ); + rWrtSh.DelRight(); + } + else + { + rWrtSh.EnterStdMode(); + } + + if( !bDelSel && aFldMgr.GetCurFld() && TYP_FORMELFLD == aFldMgr.GetCurTypeId() ) + aFldMgr.UpdateCurFld( aFldMgr.GetCurFld()->GetFormat(), aEmptyStr, sFormula ); + else if( sFormula.Len() ) + { + if( rWrtSh.IsCrsrInTbl() ) + { + SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA ); + aSet.Put( SwTblBoxFormula( sFormula )); + rWrtSh.SetTblBoxFormulaAttrs( aSet ); + rWrtSh.UpdateTable(); + } + else + { + SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter(); + ULONG nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM); + SwInsertFld_Data aData(TYP_FORMELFLD, nsSwGetSetExpType::GSE_FORMULA, aEmptyStr, sFormula, nSysNumFmt); + aFldMgr.InsertFld(aData); + } + } + + if( bDelSel ) + rWrtSh.EndUndo( UNDO_END ); + rWrtSh.EndAllAction(); + rReq.Done(); + } + else + { + rWrtSh.EndAllTblBoxEdit(); + pVFrame->ToggleChildWindow( nId ); + if( !pVFrame->HasChildWindow( nId ) ) + pVFrame->GetBindings().InvalidateAll( TRUE ); + rReq.Ignore(); + } + } + + break; + case FN_TABLE_UNSET_READ_ONLY: + { + rWrtSh.UnProtectTbls(); + } + break; + case FN_EDIT_HYPERLINK: + GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG); + break; + case FN_REMOVE_HYPERLINK: + { + BOOL bSel = rWrtSh.HasSelection(); + if(!bSel) + { + rWrtSh.StartAction(); + rWrtSh.Push(); + if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT )) + rWrtSh.SelWrd(); + } + //now remove the attribute + SvUShortsSort aAttribs; + aAttribs.Insert( RES_TXTATR_INETFMT ); + rWrtSh.ResetAttr( &aAttribs ); + if(!bSel) + { + rWrtSh.Pop(FALSE); + rWrtSh.EndAction(); + } + } + break; + case SID_ATTR_BRUSH_CHAR : + case SID_ATTR_CHAR_SCALEWIDTH : + case SID_ATTR_CHAR_ROTATED : + case FN_TXTATR_INET : + case FN_INSERT_HYPERLINK: + { + USHORT nWhich = GetPool().GetWhich( nSlot ); + if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET ) + bUseDialog = FALSE; + // intentionally no break + } + case SID_CHAR_DLG: + { + lcl_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq ); + } + break; + case SID_CHAR_DLG_FOR_PARAGRAPH: + { + rWrtSh.Push(); //save current cursor + SwLangHelper::SelectCurrentPara( rWrtSh ); + lcl_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq ); + rWrtSh.Pop( FALSE ); //restore old cursor + } + break; + case SID_ATTR_LRSPACE : + case SID_ATTR_ULSPACE : + case SID_ATTR_BRUSH : + case SID_PARA_VERTALIGN : + case SID_ATTR_PARA_NUMRULE : + case SID_ATTR_PARA_REGISTER : + case SID_ATTR_PARA_PAGENUM : + case FN_FORMAT_LINENUMBER : + case FN_NUMBER_NEWSTART : + case FN_NUMBER_NEWSTART_AT : + case FN_FORMAT_DROPCAPS : + case FN_DROP_TEXT: + { + USHORT nWhich = GetPool().GetWhich( nSlot ); + if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET ) + bUseDialog = FALSE; + // intentionally no break + + } + case SID_PARA_DLG: + { + FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView())); + SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric))); + SfxItemSet aCoreSet( GetPool(), + RES_PARATR_BEGIN, RES_PARATR_END - 1, + // --> OD 2008-02-25 #refactorlists# + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1, + // <-- + RES_FRMATR_BEGIN, RES_FRMATR_END - 1, + SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS, + SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS, + SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP, + SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM, + SID_HTML_MODE, SID_HTML_MODE, + FN_PARAM_1, FN_PARAM_1, + FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT, + FN_DROP_TEXT, FN_DROP_CHAR_STYLE_NAME, + 0); + // --> OD 2008-01-16 #newlistlevelattrs# + // get also the list level indent values merged as LR-SPACE item, if needed. + rWrtSh.GetCurAttr( aCoreSet, true ); + // <-- + aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, + ::GetHtmlMode(GetView().GetDocShell()))); + + // Tabulatoren, DefaultTabs ins ItemSet Stecken + const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&) + GetPool().GetDefaultItem(RES_PARATR_TABSTOP); + + USHORT nDefDist = ::GetTabDist( rDefTabs ); + SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist ); + aCoreSet.Put( aDefDistItem ); + + // Aktueller Tab + SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 ); + aCoreSet.Put( aTabPos ); + + // linker Rand als Offset + //#i24363# tab stops relative to indent + const long nOff = rWrtSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) ? + ((SvxLRSpaceItem&)aCoreSet.Get( RES_LR_SPACE )).GetTxtLeft() : 0; + SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); + aCoreSet.Put( aOff ); + + // BoxInfo setzen + ::PrepareBoxInfo( aCoreSet, rWrtSh ); + + //aktuelles Seitenformat + ::SwToSfxPageDescAttr( aCoreSet ); + + UINT16 nDefPage = 0; + if( pItem ) + nDefPage = ((SfxUInt16Item *)pItem)->GetValue(); + + // Numerierungseigenschaften + if(rWrtSh.GetCurNumRule()) + { + SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart() ); + aCoreSet.Put(aStart); + // --> OD 2008-02-29 #refactorlists# +// SfxUInt16Item aStartAt(FN_NUMBER_NEWSTART_AT, +// rWrtSh.IsNodeNumStart()); + SfxUInt16Item aStartAt( FN_NUMBER_NEWSTART_AT, + rWrtSh.GetNodeNumStart() ); + // <-- + aCoreSet.Put(aStartAt); + } + SfxAbstractTabDialog* pDlg = NULL; + + if ( bUseDialog && GetActiveView() ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet,DLG_STD, DLG_PARA,NULL, FALSE, nDefPage ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + } + SfxItemSet* pSet = NULL; + if ( !bUseDialog ) + { + pSet = (SfxItemSet*) pArgs; + + } + else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) + { + // Defaults evtl umsetzen + pSet = (SfxItemSet*)pDlg->GetOutputItemSet(); + USHORT nNewDist; + if( SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, FALSE, &pItem ) && + nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) ) + { + SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ); + MakeDefTabs( nNewDist, aDefTabs ); + rWrtSh.SetDefault( aDefTabs ); + pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS ); + } + + if ( SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_1,FALSE,&pItem) ) + { + pSet->Put(SfxStringItem(FN_DROP_TEXT, ((const SfxStringItem*)pItem)->GetValue())); + pSet->ClearItem(FN_PARAM_1); + } + + if( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_DROP, FALSE, &pItem )) + { + String sCharStyleName; + if(((const SwFmtDrop*)pItem)->GetCharFmt()) + sCharStyleName = ((const SwFmtDrop*)pItem)->GetCharFmt()->GetName(); + pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName)); + } + } + + if ( pSet ) + { + rReq.Done( *pSet ); + ::SfxToSwPageDescAttr( rWrtSh, *pSet ); + // --> OD 2006-12-06 #i56253# + // enclose all undos. + // Thus, check conditions, if actions will be performed. + const bool bUndoNeeded( pSet->Count() || + SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) || + SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) ); + if ( bUndoNeeded ) + { + rWrtSh.StartUndo( UNDO_INSATTR ); + } + // <-- + if( pSet->Count() ) + { + rWrtSh.StartAction(); +// rWrtSh.StartUndo( UNDO_START ); + if ( SFX_ITEM_SET == pSet->GetItemState(FN_DROP_TEXT, FALSE, &pItem) ) + { + if ( ((SfxStringItem*)pItem)->GetValue().Len() ) + rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue()); + } + rWrtSh.SetAttr( *pSet ); +// rWrtSh.EndUndo( UNDO_END ); + rWrtSh.EndAction(); + SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); + if(pColl && pColl->IsAutoUpdateFmt()) + { + rWrtSh.AutoUpdatePara(pColl, *pSet); + } + } + + if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ) + { + //SetNumRuleStart(TRUE) restarts the numbering at the value + //that is defined at the starting point of the numbering level + //otherwise the SetNodeNumStart() value determines the start + //if it's set to something different than USHRT_MAX + + BOOL bStart = ((SfxBoolItem&)pSet->Get(FN_NUMBER_NEWSTART)).GetValue(); + // --> OD 2007-06-11 #b6560525# + // Default value for restart value has to be USHRT_MAX + // in order to indicate that the restart value of the list + // style has to be used on restart. + USHORT nNumStart = USHRT_MAX; + // <-- + if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) ) + { + nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue(); + } + rWrtSh.SetNumRuleStart(bStart); + rWrtSh.SetNodeNumStart(nNumStart); + } + else if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) ) + { + USHORT nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue(); + rWrtSh.SetNodeNumStart(nNumStart); + rWrtSh.SetNumRuleStart(FALSE); + } + // --> OD 2006-12-06 #i56253# + if ( bUndoNeeded ) + { + rWrtSh.EndUndo( UNDO_INSATTR ); + } + // <-- + } + + delete pDlg; + } + break; + case FN_NUM_CONTINUE: + { + // --> OD 2008-03-18 #refactorlists# + String sContinuedListId; + const SwNumRule* pRule = + rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId ); + // --> OD 2009-08-26 #i86492# + // Search also for bullet list + if ( !pRule ) + { + pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId ); + } + // <-- + if ( pRule ) + { + rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId ); + } + // <-- + } + break; + case FN_SELECT_PARA: + { + if(!rWrtSh.IsSttOfPara()) + rWrtSh.SttPara(FALSE); + else + rWrtSh.EnterStdMode(); + rWrtSh.EndPara(TRUE); + } + break; + + case SID_DEC_INDENT: + case SID_INC_INDENT: + rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot, + rReq.GetModifier() != KEY_MOD1 ); + rReq.Done(); + break; + case FN_DEC_INDENT_OFFSET: + case FN_INC_INDENT_OFFSET: + rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot, + rReq.GetModifier() == KEY_MOD1 ); + rReq.Done(); + break; + + case SID_ATTR_CHAR_COLOR2: + { + if(pItem) + { + Color aSet = ((const SvxColorItem*)pItem)->GetValue(); + SwEditWin& rEditWin = GetView().GetEditWin(); + rEditWin.SetTextColor(aSet); + SwApplyTemplate* pApply = rEditWin.GetApplyTemplate(); + SvxColorItem aItem(aSet, RES_CHRATR_COLOR); + + // besteht eine Selektion, wird sie gleich gefaerbt + if(!pApply && rWrtSh.HasSelection()) + { + rWrtSh.SetAttr(SvxColorItem (aSet, RES_CHRATR_COLOR)); + } + else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT) + { + GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_EXT); + } + + rReq.Done(); +/* OS 22.02.97 18:40 Das alte Verhalten ist unerwuenscht + SwEditWin& rEdtWin = GetView().GetEditWin(); + + SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); + SvxColorItem aItem(aSet, RES_CHRATR_COLOR); + + if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT) + { + GetShell().SetAttr(aItem); + } +*/ + } + } + break; + case SID_ATTR_CHAR_COLOR_BACKGROUND: + { + SwEditWin& rEdtWin = GetView().GetEditWin(); + SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); + rEdtWin.SetTextBackColorTransparent(0 == pItem); + Color aSet; + if(pItem) + { + aSet = ((const SvxColorItem*)pItem)->GetValue(); + rEdtWin.SetTextBackColor(aSet); + } + if(!pApply && (rWrtSh.HasSelection() || rReq.IsAPI())) + { + SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND); + if(pItem) + aBrushItem.SetColor(aSet); + else + aBrushItem.SetColor(Color(COL_TRANSPARENT)); + rWrtSh.SetAttr( aBrushItem ); + } + else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT) + { + GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT); + } + + rReq.Done(); + +/* OS 22.02.97 18:40 Das alte Verhalten ist unerwuenscht + if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT) + { + Brush aBrush(pItem ? BRUSH_SOLID : BRUSH_NULL); + if(pItem) + aBrush.SetColor( aSet ); + GetShell().SetAttr( SvxBrushItem(aBrush, RES_CHRATR_BACKGROUND) ); + } +*/ + } + break; + case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: + case SID_ATTR_CHAR_COLOR_EXT: + { + SwEditWin& rEdtWin = GetView().GetEditWin(); + SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); + SwApplyTemplate aTempl; + BOOL bSelection = rWrtSh.HasSelection(); + if(bSelection) + { + + if(nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT) + { + rWrtSh.SetAttr( SvxBrushItem( + rEdtWin.GetTextBackColor(), RES_CHRATR_BACKGROUND) ); + } + else + rWrtSh.SetAttr( SvxColorItem( rEdtWin.GetTextColor(), + RES_CHRATR_COLOR) ); + } + else + { + if(!pApply || pApply->nColor != nSlot) + aTempl.nColor = nSlot; + rEdtWin.SetApplyTemplate(aTempl); + } + + rReq.Done(); + } + break; + + case FN_NUM_BULLET_MOVEDOWN: + if (!rWrtSh.IsAddMode()) + rWrtSh.MoveParagraph(1); + rReq.Done(); + break; + + case FN_NUM_BULLET_MOVEUP: + if (!rWrtSh.IsAddMode()) + rWrtSh.MoveParagraph(-1); + rReq.Done(); + break; + case SID_RUBY_DIALOG: + case SID_HYPERLINK_DIALOG: + { + SfxRequest aReq(nSlot, SFX_CALLMODE_SLOT, SFX_APP()->GetPool()); + GetView().GetViewFrame()->ExecuteSlot( aReq); + rReq.Ignore(); + } + break; + case FN_INSERT_PAGEHEADER: + case FN_INSERT_PAGEFOOTER: + if(pArgs && pArgs->Count()) + { + String sStyleName; + if(pItem) + sStyleName = ((const SfxStringItem*)pItem)->GetValue(); + BOOL bOn = TRUE; + if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem)) + bOn = ((const SfxBoolItem*)pItem)->GetValue(); + ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI()); + rReq.Done(); + } + break; + case FN_READONLY_SELECTION_MODE : + if(GetView().GetDocShell()->IsReadOnly()) + { + rWrtSh.SetReadonlySelectionOption( + !rWrtSh.GetViewOptions()->IsSelectionInReadonly()); + rWrtSh.ShowCrsr(); + } + break; + case FN_SELECTION_MODE_DEFAULT: + case FN_SELECTION_MODE_BLOCK : + { + bool bSetBlockMode = !rWrtSh.IsBlockMode(); + if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem)) + bSetBlockMode = ((const SfxBoolItem*)pItem)->GetValue(); + if( ( nSlot == FN_SELECTION_MODE_DEFAULT ) ^ bSetBlockMode ) + rWrtSh.EnterBlockMode(); + else + rWrtSh.EnterStdMode(); + SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); + rBnd.Invalidate(FN_STAT_SELMODE); + rBnd.Update(FN_STAT_SELMODE); + } + break; + case SID_OPEN_HYPERLINK: + case FN_COPY_HYPERLINK_LOCATION: + { + SfxItemSet aSet(GetPool(), + RES_TXTATR_INETFMT, + RES_TXTATR_INETFMT); + rWrtSh.GetCurAttr(aSet); + if(SFX_ITEM_SET <= aSet.GetItemState( RES_TXTATR_INETFMT, TRUE )) + { + const SwFmtINetFmt& rINetFmt = dynamic_cast<const SwFmtINetFmt&>( aSet.Get(RES_TXTATR_INETFMT, TRUE) ); + if( nSlot == FN_COPY_HYPERLINK_LOCATION ) + { + ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard(); + vcl::unohelper::TextDataObject::CopyStringTo( + rINetFmt.GetValue(), + xClipboard ); + } + else + rWrtSh.ClickToINetAttr(rINetFmt, URLLOAD_NOFILTER); + } + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_FORMAT_APPLY_HEAD1: + { + } + break; + case FN_FORMAT_APPLY_HEAD2: + { + } + break; + case FN_FORMAT_APPLY_HEAD3: + { + } + break; + case FN_FORMAT_APPLY_DEFAULT: + { + } + break; + case FN_FORMAT_APPLY_TEXTBODY: + { + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwWrtShell &rSh = GetShell(); + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; + default: + ASSERT(!this, falscher Dispatcher); + return; + } +} + + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void SwTextShell::GetState( SfxItemSet &rSet ) +{ + SwWrtShell &rSh = GetShell(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_LANGUAGE_STATUS: + { + // the value of used script types + String aScriptTypesInUse( String::CreateFromInt32( rSh.GetScriptType() ) ); + + SvtLanguageTable aLangTable; + + // get keyboard language + String aKeyboardLang; + LanguageType nLang = LANGUAGE_DONTKNOW; + SwEditWin& rEditWin = GetView().GetEditWin(); + nLang = rEditWin.GetInputLanguage(); + if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) + aKeyboardLang = aLangTable.GetString( nLang ); + + // get the language that is in use + const String aMultipleLanguages = String::CreateFromAscii("*"); + String aCurrentLang = aMultipleLanguages; + nLang = SwLangHelper::GetCurrentLanguage( rSh ); + if (nLang != LANGUAGE_DONTKNOW) + aCurrentLang = aLangTable.GetString( nLang ); + + // build sequence for status value + uno::Sequence< ::rtl::OUString > aSeq( 4 ); + aSeq[0] = aCurrentLang; + aSeq[1] = aScriptTypesInUse; + aSeq[2] = aKeyboardLang; + aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( rSh ); + + // set sequence as status value + SfxStringListItem aItem( SID_LANGUAGE_STATUS ); + aItem.SetStringList( aSeq ); + rSet.Put( aItem, SID_LANGUAGE_STATUS ); + } + break; + + case FN_NUMBER_NEWSTART : + if(!rSh.GetCurNumRule()) + rSet.DisableItem(nWhich); + else + rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART, + rSh.IsNumRuleStart())); + break; + case FN_EDIT_FORMULA: + case SID_CHARMAP: + { + const int nType = rSh.GetSelectionType(); + if (!(nType & nsSelectionType::SEL_TXT) && + !(nType & nsSelectionType::SEL_TBL) && + !(nType & nsSelectionType::SEL_NUM)) + rSet.DisableItem(nWhich); + } + break; + + case FN_INSERT_ENDNOTE: + case FN_INSERT_FOOTNOTE: + case FN_INSERT_FOOTNOTE_DLG: + { + const USHORT nNoType = FRMTYPE_FLY_ANY | FRMTYPE_HEADER | + FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE; + if ( (rSh.GetFrmType(0,TRUE) & nNoType) ) + rSet.DisableItem(nWhich); + } + break; + case FN_INSERT_TABLE: + if ( rSh.GetTableFmt() || + (rSh.GetFrmType(0,TRUE) & FRMTYPE_FOOTNOTE) ) + rSet.DisableItem( nWhich ); + break; + + case FN_CALCULATE: + if ( !rSh.IsSelection() ) + rSet.DisableItem(nWhich); + break; + case FN_GOTO_REFERENCE: + { + SwField *pFld = rSh.GetCurFld(); + if ( !pFld || (pFld && pFld->GetTypeId() != TYP_GETREFFLD) ) + rSet.DisableItem(nWhich); + } + break; + case FN_AUTOFORMAT_AUTO: + { + rSet.Put( SfxBoolItem( nWhich, SvxAutoCorrCfg::Get()->IsAutoFmtByInput() )); + } + break; + case FN_GLOSSARY_DLG: + { + rSet.Put(SfxBoolItem(nWhich), TRUE); + } + break; + + case SID_DEC_INDENT: + case SID_INC_INDENT: + { + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES; + if( (nHtmlMode == HTMLMODE_ON) || !rSh.IsMoveLeftMargin( + SID_INC_INDENT == nWhich, TRUE )) + rSet.DisableItem( nWhich ); + } + break; + + case FN_DEC_INDENT_OFFSET: + case FN_INC_INDENT_OFFSET: + { + USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); + nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES; + if( (nHtmlMode == HTMLMODE_ON) || + !rSh.IsMoveLeftMargin( FN_INC_INDENT_OFFSET == nWhich, + FALSE )) + rSet.DisableItem( nWhich ); + } + break; + + case SID_ATTR_CHAR_COLOR2: + { + rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2)); + } + break; + case SID_ATTR_CHAR_COLOR_BACKGROUND: + { + if(GetView().GetEditWin().IsTextBackColorTransparent()) + rSet.Put(SvxColorItem(Color(COL_TRANSPARENT), SID_ATTR_CHAR_COLOR_BACKGROUND)); + else + rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND)); + } + break; + case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: + case SID_ATTR_CHAR_COLOR_EXT: + { + SwEditWin& rEdtWin = GetView().GetEditWin(); + SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); + rSet.Put(SfxBoolItem(nWhich, pApply && pApply->nColor == nWhich)); + } + break; + case FN_INSERT_BOOKMARK: + if( rSh.IsTableMode() ) + rSet.DisableItem( nWhich ); + break; + + case FN_INSERT_PAGEHEADER: + case FN_INSERT_PAGEFOOTER: + { +#ifndef CHECK_MENU + rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() )); +#else + // Seitenvorlagen besorgen + BOOL bFound = FALSE; + USHORT n, nCnt = rSh.GetPageDescCnt(); + for( n = 0; n < nCnt; ++n ) + { + const SwPageDesc& rDesc = rSh.GetPageDesc( n ); + if( FN_INSERT_PAGEHEADER == nWhich + ? !rDesc.GetMaster().GetHeader().IsActive() + : !rDesc.GetMaster().GetFooter().IsActive() ) + { + bFound = TRUE; + break; + } + } + + if( bFound ) + rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() )); + else + rSet.DisableItem( nWhich ); +#endif + } + break; + case FN_TABLE_SORT_DIALOG: + case FN_SORTING_DLG: + if(!rSh.HasSelection() || + (FN_TABLE_SORT_DIALOG == nWhich && !rSh.GetTableFmt())) + rSet.DisableItem( nWhich ); + break; + case SID_RUBY_DIALOG: + { + SvtCJKOptions aCJKOptions; + if(!aCJKOptions.IsRubyEnabled()) + { + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); + rSet.DisableItem(nWhich); + } + else + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); + break; + } + //no break! + case SID_HYPERLINK_DIALOG: + if( GetView().GetDocShell()->IsReadOnly() || + (!GetView().GetViewFrame()->HasChildWindow(nWhich) && + rSh.HasReadonlySel()) ) + rSet.DisableItem(nWhich); + else + rSet.Put(SfxBoolItem( nWhich, 0 != GetView(). + GetViewFrame()->GetChildWindow( nWhich ) )); + break; + case FN_EDIT_HYPERLINK: + case FN_REMOVE_HYPERLINK: + case FN_COPY_HYPERLINK_LOCATION: + { + SfxItemSet aSet(GetPool(), + RES_TXTATR_INETFMT, + RES_TXTATR_INETFMT); + rSh.GetCurAttr(aSet); + if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, TRUE ) || rSh.HasReadonlySel()) + { + rSet.DisableItem(nWhich); + } + } + break; + case SID_TRANSLITERATE_HALFWIDTH: + case SID_TRANSLITERATE_FULLWIDTH: + case SID_TRANSLITERATE_HIRAGANA: + case SID_TRANSLITERATE_KATAGANA: + { + SvtCJKOptions aCJKOptions; + if(!aCJKOptions.IsChangeCaseMapEnabled()) + { + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); + rSet.DisableItem(nWhich); + } + else + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); + } + break; + case FN_READONLY_SELECTION_MODE : + if(!GetView().GetDocShell()->IsReadOnly()) + rSet.DisableItem( nWhich ); + else + { + rSet.Put(SfxBoolItem(nWhich, rSh.GetViewOptions()->IsSelectionInReadonly())); + } + break; + case FN_SELECTION_MODE_DEFAULT: + case FN_SELECTION_MODE_BLOCK : + rSet.Put(SfxBoolItem(nWhich, (nWhich == FN_SELECTION_MODE_DEFAULT) != rSh.IsBlockMode())); + break; + case SID_OPEN_HYPERLINK: + { + SfxItemSet aSet(GetPool(), + RES_TXTATR_INETFMT, + RES_TXTATR_INETFMT); + rSh.GetCurAttr(aSet); + if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, FALSE )) + rSet.DisableItem(nWhich); + } + break; + case SID_OPEN_SMARTTAGMENU: + { + uno::Sequence< rtl::OUString > aSmartTagTypes; + uno::Sequence< uno::Reference< container::XStringKeyMap > > aStringKeyMaps; + uno::Reference<text::XTextRange> xRange; + + rSh.GetSmartTagTerm( aSmartTagTypes, aStringKeyMaps, xRange ); + + if ( xRange.is() && aSmartTagTypes.getLength() ) + { + uno::Sequence < uno::Sequence< uno::Reference< smarttags::XSmartTagAction > > > aActionComponentsSequence; + uno::Sequence < uno::Sequence< sal_Int32 > > aActionIndicesSequence; + + const SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get(); + rSmartTagMgr.GetActionSequences( aSmartTagTypes, + aActionComponentsSequence, + aActionIndicesSequence ); + + uno::Reference <frame::XController> xController = GetView().GetController(); + const lang::Locale aLocale( SW_BREAKITER()->GetLocale( (LanguageType)GetAppLanguage() ) ); + const rtl::OUString aApplicationName( rSmartTagMgr.GetApplicationName() ); + const rtl::OUString aRangeText = xRange->getString(); + + const SvxSmartTagItem aItem( nWhich, + aActionComponentsSequence, + aActionIndicesSequence, + aStringKeyMaps, + xRange, + xController, + aLocale, + aApplicationName, + aRangeText ); + + rSet.Put( aItem ); + } + else + rSet.DisableItem(nWhich); + } + break; + case FN_NUM_CONTINUE: + { + // --> OD 2009-08-26 #i86492# + // Allow continuation of previous list, even if at current cursor + // a list is active. +// if ( rSh.GetCurNumRule() ) +// rSet.DisableItem(nWhich); +// else + // <-- + { + // --> OD 2009-08-26 #i86492# + // Search also for bullet list + String aDummy; + const SwNumRule* pRule = + rSh.SearchNumRule( false, true, false, -1, aDummy ); + if ( !pRule ) + { + pRule = rSh.SearchNumRule( false, false, false, -1, aDummy ); + } + // <-- + if ( !pRule ) + rSet.DisableItem(nWhich); + } + } + break; + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + SvtCTLOptions aCTLOptions; + sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); + if(!bEnabled) + rSet.DisableItem(nWhich); + } + break; + } + nWhich = aIter.NextWhich(); + } +} +/* -----------------------------2002/07/05 10:31------------------------------ + Switch on/off header of footer of a page style - if an empty name is + given all styles are changed + ---------------------------------------------------------------------------*/ +void SwTextShell::ChangeHeaderOrFooter( + const String& rStyleName, BOOL bHeader, BOOL bOn, BOOL bShowWarning) +{ + SwWrtShell& rSh = GetShell(); + rSh.StartAllAction(); + rSh.StartUndo( UNDO_HEADER_FOOTER ); // #i7983# + BOOL bExecute = TRUE; + BOOL bCrsrSet = FALSE; + for( USHORT nFrom = 0, nTo = rSh.GetPageDescCnt(); + nFrom < nTo; ++nFrom ) + { + int bChgd = FALSE; + SwPageDesc aDesc( rSh.GetPageDesc( nFrom )); + String sTmp(aDesc.GetName()); + if( !rStyleName.Len() || rStyleName == sTmp ) + { + if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() && + (bHeader && aDesc.GetMaster().GetHeader().IsActive() || + !bHeader && aDesc.GetMaster().GetFooter().IsActive())) + { + bShowWarning = FALSE; + //Actions have to be closed while the dialog is showing + rSh.EndAllAction(); + + Window* pParent = &GetView().GetViewFrame()->GetWindow(); + BOOL bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT, + DIALOG_MGR() ) ).Execute(); + bExecute = bRet; + rSh.StartAllAction(); + } + if( bExecute ) + { + bChgd = TRUE; + SwFrmFmt &rMaster = aDesc.GetMaster(); + if(bHeader) + rMaster.SetFmtAttr( SwFmtHeader( bOn )); + else + rMaster.SetFmtAttr( SwFmtFooter( bOn )); + if( bOn ) + { + SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE ); + SwFrmFmt* pFmt = bHeader ? + (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() : + (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt(); + pFmt->SetFmtAttr( aUL ); + } + } + if( bChgd ) + { + rSh.ChgPageDesc( nFrom, aDesc ); + + if( !bCrsrSet && bOn ) + bCrsrSet = rSh.SetCrsrInHdFt( + !rStyleName.Len() ? USHRT_MAX : nFrom, + bHeader ); + } + } + } + rSh.EndUndo( UNDO_HEADER_FOOTER ); // #i7983# + rSh.EndAllAction(); +} + diff --git a/sw/source/ui/shells/textsh2.cxx b/sw/source/ui/shells/textsh2.cxx new file mode 100644 index 000000000000..2d267e926fc8 --- /dev/null +++ b/sw/source/ui/shells/textsh2.cxx @@ -0,0 +1,312 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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" + + + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <svtools/svmedit.hxx> +#include <svl/eitem.hxx> +#include <svl/whiter.hxx> +#include <sfx2/event.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#ifndef _MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#include <svl/stritem.hxx> +#include <svl/itemset.hxx> +#include <sfx2/request.hxx> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdb/XQueriesSupplier.hpp> +#include <com/sun/star/sdb/XDatabaseAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <sfx2/frame.hxx> +#include <fldmgr.hxx> +#include <fldbas.hxx> +#include "dbmgr.hxx" +#include <comphelper/uno3.hxx> +#include <svx/dataaccessdescriptor.hxx> +#include <memory> + +#include <vcl/svapp.hxx> + +#include "view.hxx" +#include "wrtsh.hxx" +#include "swtypes.hxx" +#include "cmdid.h" +#include "swevent.hxx" +#include "shells.hrc" +#include "textsh.hxx" +#include "swabstdlg.hxx" +#include "dbui.hrc" + +#include <unomid.h> + +using namespace ::svx; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; + + +#define DB_DD_DELIM 0x0b + +struct DBTextStruct_Impl +{ + SwDBData aDBData; + Sequence<Any> aSelection; + Reference<XResultSet> xCursor; + Reference<XConnection> xConnection; +}; +inline void AddSelList( List& rLst, long nRow ) +{ + rLst.Insert( (void*)nRow , LIST_APPEND ); +} +void SwTextShell::ExecDB(SfxRequest &rReq) +{ + const SfxItemSet *pArgs = rReq.GetArgs(); + SwNewDBMgr* pNewDBMgr = GetShell().GetNewDBMgr(); + USHORT nSlot = rReq.GetSlot(); + ::rtl::OUString sSourceArg, sCommandArg; + sal_Int32 nCommandTypeArg = 0; + + const SfxPoolItem* pSourceItem = 0; + const SfxPoolItem* pCursorItem = 0; + const SfxPoolItem* pConnectionItem = 0; + const SfxPoolItem* pCommandItem = 0; + const SfxPoolItem* pCommandTypeItem = 0; + const SfxPoolItem* pSelectionItem = 0; + + // first get the selection of rows to be inserted + pArgs->GetItemState(FN_DB_DATA_SELECTION_ANY, FALSE, &pSelectionItem); + + Sequence<Any> aSelection; + if(pSelectionItem) + ((SfxUsrAnyItem*)pSelectionItem)->GetValue() >>= aSelection; + + // get the data source name + pArgs->GetItemState(FN_DB_DATA_SOURCE_ANY, FALSE, &pSourceItem); + if(pSourceItem) + ((const SfxUsrAnyItem*)pSourceItem)->GetValue() >>= sSourceArg; + + // get the command + pArgs->GetItemState(FN_DB_DATA_COMMAND_ANY, FALSE, &pCommandItem); + if(pCommandItem) + ((const SfxUsrAnyItem*)pCommandItem)->GetValue() >>= sCommandArg; + + // get the command type + pArgs->GetItemState(FN_DB_DATA_COMMAND_TYPE_ANY, FALSE, &pCommandTypeItem); + if(pCommandTypeItem) + ((const SfxUsrAnyItem*)pCommandTypeItem)->GetValue() >>= nCommandTypeArg; + + Reference<XConnection> xConnection; + pArgs->GetItemState(FN_DB_CONNECTION_ANY, FALSE, &pConnectionItem); + if ( pConnectionItem ) + ((const SfxUsrAnyItem*)pConnectionItem)->GetValue() >>= xConnection; + // may be we even get no connection + if ( !xConnection.is() ) + { + Reference<XDataSource> xSource; + xConnection = pNewDBMgr->GetConnection(sSourceArg, xSource); + } + if(!xConnection.is()) + return ; + + // get the cursor, we use to travel, may be NULL + Reference<XResultSet> xCursor; + pArgs->GetItemState(FN_DB_DATA_CURSOR_ANY, FALSE, &pCursorItem); + if ( pCursorItem ) + ((const SfxUsrAnyItem*)pCursorItem)->GetValue() >>= xCursor; + + switch (nSlot) + { + case FN_QRY_INSERT: + { + if(pSourceItem && pCommandItem && pCommandTypeItem) + { + DBTextStruct_Impl* pNew = new DBTextStruct_Impl; + pNew->aDBData.sDataSource = sSourceArg; + pNew->aDBData.sCommand = sCommandArg; + pNew->aDBData.nCommandType = nCommandTypeArg; + pNew->aSelection = aSelection; + //if the cursor is NULL, it must be created inside InsertDBTextHdl + // because it called via a PostUserEvent + pNew->xCursor = xCursor; + pNew->xConnection = xConnection; + + Application::PostUserEvent( STATIC_LINK( this, SwBaseShell, + InsertDBTextHdl ), pNew ); + // the pNew will be removed in InsertDBTextHdl !! + } + } + break; + + case FN_QRY_MERGE_FIELD: + { + // we don't get any cursor, so we must create our own + BOOL bDisposeResultSet = FALSE; + if ( !xCursor.is() ) + { + xCursor = SwNewDBMgr::createCursor(sSourceArg,sCommandArg,nCommandTypeArg,xConnection); + bDisposeResultSet = xCursor.is(); + } + + ODataAccessDescriptor aDescriptor; + aDescriptor.setDataSource(sSourceArg); + aDescriptor[daCommand] <<= sCommandArg; + aDescriptor[daCursor] <<= xCursor; + aDescriptor[daSelection] <<= aSelection; + aDescriptor[daCommandType] <<= nCommandTypeArg; + + SwMergeDescriptor aMergeDesc( DBMGR_MERGE, *GetShellPtr(), aDescriptor ); + pNewDBMgr->MergeNew(aMergeDesc); + + if ( bDisposeResultSet ) + ::comphelper::disposeComponent(xCursor); + } + break; + + case FN_QRY_INSERT_FIELD: + { + const SfxPoolItem* pColumnItem = 0; + const SfxPoolItem* pColumnNameItem = 0; + + pArgs->GetItemState(FN_DB_COLUMN_ANY, FALSE, &pColumnItem); + pArgs->GetItemState(FN_DB_DATA_COLUMN_NAME_ANY, FALSE, &pColumnNameItem); + + ::rtl::OUString sColumnName; + if(pColumnNameItem) + ((SfxUsrAnyItem*)pColumnNameItem)->GetValue() >>= sColumnName; + String sDBName = sSourceArg; + sDBName += DB_DELIM; + sDBName += (String)sCommandArg; + sDBName += DB_DELIM; + sDBName += String::CreateFromInt32(nCommandTypeArg); + sDBName += DB_DELIM; + sDBName += (String)sColumnName; + + SwFldMgr aFldMgr(GetShellPtr()); + SwInsertFld_Data aData(TYP_DBFLD, 0, sDBName, aEmptyStr, 0, FALSE, TRUE); + if(pConnectionItem) + aData.aDBConnection = ((SfxUsrAnyItem*)pConnectionItem)->GetValue(); + if(pColumnItem) + aData.aDBColumn = ((SfxUsrAnyItem*)pColumnItem)->GetValue(); + aFldMgr.InsertFld(aData); + SfxViewFrame* pViewFrame = GetView().GetViewFrame(); + uno::Reference< frame::XDispatchRecorder > xRecorder = + pViewFrame->GetBindings().GetRecorder(); + if ( xRecorder.is() ) + { + SfxRequest aReq( pViewFrame, FN_INSERT_DBFIELD ); + aReq.AppendItem( SfxUInt16Item(FN_PARAM_FIELD_TYPE, TYP_DBFLD)); + aReq.AppendItem( SfxStringItem( FN_INSERT_DBFIELD, sDBName )); + aReq.AppendItem( SfxStringItem( FN_PARAM_1, sCommandArg )); + aReq.AppendItem( SfxStringItem( FN_PARAM_2, sColumnName )); + aReq.AppendItem( SfxInt32Item( FN_PARAM_3, nCommandTypeArg)); + aReq.Done(); + } + } + break; + + default: + ASSERT(!this, falscher Dispatcher); + return; + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +IMPL_STATIC_LINK( SwBaseShell, InsertDBTextHdl, DBTextStruct_Impl*, pDBStruct ) +{ + if( pDBStruct ) + { + sal_Bool bDispose = sal_False; + Reference< sdbc::XConnection> xConnection = pDBStruct->xConnection; + Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,pDBStruct->aDBData.sDataSource); + // #111987# the connection is disposed an so no parent has been found + if(xConnection.is() && !xSource.is()) + return 0; + + if ( !xConnection.is() ) + { + xConnection = SwNewDBMgr::GetConnection(pDBStruct->aDBData.sDataSource, xSource); + bDispose = sal_True; + } + + Reference< XColumnsSupplier> xColSupp; + if(xConnection.is()) + xColSupp = SwNewDBMgr::GetColumnSupplier(xConnection, + pDBStruct->aDBData.sCommand, + pDBStruct->aDBData.nCommandType == CommandType::QUERY ? + SW_DB_SELECT_QUERY : SW_DB_SELECT_TABLE); + + if( xColSupp.is() ) + { + SwDBData aDBData = pDBStruct->aDBData; + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + ::std::auto_ptr<AbstractSwInsertDBColAutoPilot>pDlg (pFact->CreateSwInsertDBColAutoPilot( pThis->GetView(), + xSource, + xColSupp, + aDBData, + DLG_AP_INSERT_DB_SEL )); + if( RET_OK == pDlg->Execute() ) + { + Reference <XResultSet> xResSet = pDBStruct->xCursor; + pDlg->DataToDoc( pDBStruct->aSelection, xSource, xConnection, xResSet); + } + } + if ( bDispose ) + ::comphelper::disposeComponent(xConnection); + } + + delete pDBStruct; + return 0; +} + + + diff --git a/sw/source/ui/shells/txtattr.cxx b/sw/source/ui/shells/txtattr.cxx new file mode 100644 index 000000000000..9e89620bed28 --- /dev/null +++ b/sw/source/ui/shells/txtattr.cxx @@ -0,0 +1,847 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> + +#ifndef _MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#include <svl/whiter.hxx> +#include <svl/stritem.hxx> +#include <svl/itemiter.hxx> +#include <svl/ctloptions.hxx> +#include <swmodule.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/request.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/adjitem.hxx> +#include <editeng/lspcitem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/escpitem.hxx> +#include <svx/htmlmode.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/frmdiritem.hxx> +#include "paratr.hxx" + +#include <fmtinfmt.hxx> +#ifndef _DOCSH_HXX +#include <docsh.hxx> +#endif +#include <wrtsh.hxx> +#ifndef _VIEW_HXX +#include <view.hxx> +#endif +#include <viewopt.hxx> +#include <uitool.hxx> +#ifndef _TEXTSH_HXX +#include <textsh.hxx> +#endif +#include <num.hxx> +#include <swundo.hxx> +#include <fmtcol.hxx> + +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#include <globals.h> +#ifndef _SHELLS_HRC +#include <shells.hrc> +#endif +#include <SwStyleNameMapper.hxx> +#include "swabstdlg.hxx" +#include "chrdlg.hrc" +const SwTwips lFontInc = 2 * 20; // ==> PointToTwips(2) +const SwTwips lFontMaxSz = 72 * 20; // ==> PointToTwips(72) + + + + +void SwTextShell::ExecCharAttr(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + const SfxItemSet *pArgs = rReq.GetArgs(); + int eState = STATE_TOGGLE; + USHORT nWhich = rReq.GetSlot(); + + if(pArgs ) + { + const SfxPoolItem* pItem; + pArgs->GetItemState(nWhich, FALSE, &pItem); + eState = ((const SfxBoolItem &) pArgs-> + Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF; + } + + + SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 ); + if (STATE_TOGGLE == eState) + rSh.GetCurAttr( aSet ); + + switch ( nWhich ) + { + case FN_SET_SUB_SCRIPT: + case FN_SET_SUPER_SCRIPT: + { + SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT; + switch (eState) + { + case STATE_TOGGLE: + { + short nTmpEsc = ((const SvxEscapementItem&) + aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc(); + eEscape = nWhich == FN_SET_SUPER_SCRIPT ? + SVX_ESCAPEMENT_SUPERSCRIPT: + SVX_ESCAPEMENT_SUBSCRIPT; + if( nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0 || + nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0 ) + eEscape = SVX_ESCAPEMENT_OFF; + + SfxBindings& rBind = GetView().GetViewFrame()->GetBindings(); + if( nWhich == FN_SET_SUB_SCRIPT ) + rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT, + FALSE ) ); + else + rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT, + FALSE ) ); + + } + break; + case STATE_ON: + eEscape = nWhich == FN_SET_SUPER_SCRIPT ? + SVX_ESCAPEMENT_SUPERSCRIPT: + SVX_ESCAPEMENT_SUBSCRIPT; + break; + case STATE_OFF: + eEscape = SVX_ESCAPEMENT_OFF; + break; + } + SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT ); + if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT) + aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER; + else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT) + aEscape.GetEsc() = DFLT_ESC_AUTO_SUB; + if(eState != STATE_OFF ) + { + if(eEscape == FN_SET_SUPER_SCRIPT) + aEscape.GetEsc() *= -1; + } + rSh.SetAttr( aEscape ); + rReq.AppendItem( aEscape ); + rReq.Done(); + } + break; + + case FN_UPDATE_STYLE_BY_EXAMPLE: + rSh.QuickUpdateStyle(); + rReq.Done(); + break; + case FN_UNDERLINE_DOUBLE: + { + FontUnderline eUnderline = ((const SvxUnderlineItem&) + aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle(); + switch( eState ) + { + case STATE_TOGGLE: + eUnderline = eUnderline == UNDERLINE_DOUBLE ? + UNDERLINE_NONE : + UNDERLINE_DOUBLE; + break; + case STATE_ON: + eUnderline = UNDERLINE_DOUBLE; + break; + case STATE_OFF: + eUnderline = UNDERLINE_NONE; + break; + } + SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE ); + rSh.SetAttr( aUnderline ); + rReq.AppendItem( aUnderline ); + rReq.Done(); + } + break; + case FN_REMOVE_DIRECT_CHAR_FORMATS: + if( !rSh.HasReadonlySel() && rSh.IsEndPara()) + rSh.DontExpandFmt(); + break; + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } +} + + +void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq) +{ + USHORT nSlot = rReq.GetSlot(); + const SfxItemSet* pArgs = rReq.GetArgs(); + BOOL bArgs = pArgs != 0 && pArgs->Count() > 0; + int bGrow = FALSE; + SwWrtShell& rWrtSh = GetShell(); + SwTxtFmtColl* pColl = 0; + + // nur gesetzt, wenn gesamter Absatz selektiert ist und AutoUpdateFmt gesetzt ist + if( rWrtSh.HasSelection() && rWrtSh.IsSelFullPara() ) + { + pColl = rWrtSh.GetCurTxtFmtColl(); + if(pColl && !pColl->IsAutoUpdateFmt()) + pColl = 0; + } + SfxItemPool& rPool = GetPool(); + USHORT nWhich = rPool.GetWhich(nSlot); + switch ( nSlot ) + { + case FN_TXTATR_INET: + // Sonderbehandlung der PoolId des SwFmtInetFmt + if(bArgs) + { + const SfxPoolItem& rItem = pArgs->Get(nWhich ); + + SwFmtINetFmt aINetFmt((const SwFmtINetFmt&)rItem); + if( USHRT_MAX == aINetFmt.GetVisitedFmtId() ) + { + aINetFmt.SetVisitedFmtId( + SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT)); + } + if( USHRT_MAX == aINetFmt.GetINetFmtId() ) + { + aINetFmt.SetINetFmtId( + SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT)); + } + + if ( pColl ) + pColl->SetFmtAttr( aINetFmt ); + else rWrtSh.SetAttr( aINetFmt ); + rReq.Done(); + } + break; + + case FN_GROW_FONT_SIZE: + bGrow = TRUE; + // kein break !! + case FN_SHRINK_FONT_SIZE: + { + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool ); + rWrtSh.GetCurAttr( aSetItem.GetItemSet() ); + SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() ); + + const SfxPoolItem* pI; + static const USHORT aScrTypes[] = { + SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 }; + USHORT nScriptType = rWrtSh.GetScriptType(); + for( const USHORT* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp ) + if( ( nScriptType & *pScrpTyp ) && + 0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp ))) + { + SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI ); + SwTwips lSize = (SwTwips) aSize.GetHeight(); + + if (bGrow) + { + if( lSize == lFontMaxSz ) + break; // das wars, hoeher gehts nicht + if( ( lSize += lFontInc ) > lFontMaxSz ) + lSize = lFontMaxSz; + } + else + { + if( 4 == lSize ) + break; + if( ( lSize -= lFontInc ) < 4 ) + lSize = 4; + } + aSize.SetHeight( lSize ); + aAttrSet.Put( aSize ); + } + if( aAttrSet.Count() ) + { + if( pColl ) + pColl->SetFmtAttr( aAttrSet ); + else + rWrtSh.SetAttr( aAttrSet ); + } + rReq.Done(); + } + break; + + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } +} + + + +#ifdef CFRONT + +void lcl_SetAdjust(SvxAdjust eAdjst, SfxItemSet& rSet) +{ + rSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST )); +} + + + +void lcl_SetLineSpace(BYTE ePropL,SfxItemSet& rSet) +{ + SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING ); + aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + if( 100 == ePropL ) + aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; + else + aLineSpacing.SetPropLineSpace(ePropL); + rSet.Put( aLineSpacing ); +} + + + +void SwTextShell::ExecParaAttr(SfxRequest &rReq) +{ + // gleiche beide Attribute holen, ist nicht teuerer !! + SfxItemSet aSet( GetPool(), RES_PARATR_LINESPACING, RES_PARATR_ADJUST ); + + switch (rReq.GetSlot()) + { + case FN_SET_LEFT_PARA: lcl_SetAdjust(ADJLEFT,aSet); break; + case FN_SET_RIGHT_PARA: lcl_SetAdjust(ADJRIGHT,aSet); break; + case FN_SET_CENTER_PARA: lcl_SetAdjust(ADJCENTER,aSet); break; + case SID_ATTR_PARA_ADJUST_BLOCK:lcl_SetAdjust(ADJBLOCK,aSet); break; + + case FN_SET_LINE_SPACE_1: lcl_SetLineSpace(100,aSet); break; + case FN_SET_LINE_SPACE_15: lcl_SetLineSpace(150,aSet); break; + case FN_SET_LINE_SPACE_2: lcl_SetLineSpace(200,aSet); break; + + default: + DBG_ERROR("SwTextShell::ExecParaAttr falscher Dispatcher"); + return; + } + SwWrtShell& rWrtSh = GetShell(); + SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); + if(pColl && pColl->IsAutoUpdateFmt()) + { + rWrtSh.AutoUpdatePara(pColl, *pSet); + } + else + { + rWrtSh.SetAttr( aSet ); + rReq.Done( aSet ); + } +} + +#else + + + +void SwTextShell::ExecParaAttr(SfxRequest &rReq) +{ + SvxAdjust eAdjst; + BYTE ePropL; + const SfxItemSet* pArgs = rReq.GetArgs(); + + // gleich beide Attribute holen, ist nicht teuerer !! + SfxItemSet aSet( GetPool(), + RES_PARATR_LINESPACING, RES_PARATR_ADJUST, + RES_FRAMEDIR, RES_FRAMEDIR, + 0 ); + + USHORT nSlot = rReq.GetSlot(); + switch (nSlot) + { + case SID_ATTR_PARA_ADJUST: + { + if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) ) + { + const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST); + SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST ); + if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK ) + { + aAdj.SetLastBlock( rAdj.GetLastBlock() ); + aAdj.SetOneWord( rAdj.GetOneWord() ); + } + + aSet.Put(aAdj); + } + } + break; + case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SVX_ADJUST_LEFT; goto SET_ADJUST; + case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SVX_ADJUST_RIGHT; goto SET_ADJUST; + case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SVX_ADJUST_CENTER; goto SET_ADJUST; + case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SVX_ADJUST_BLOCK; goto SET_ADJUST; +SET_ADJUST: + { + aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST)); + rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), TRUE ) ); + } + break; + + case SID_ATTR_PARA_LINESPACE: + if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) )) + { + SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get( + GetPool().GetWhich(nSlot)); + aSet.Put( aLineSpace ); + } + break; + case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE; + case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE; + case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE; + +SET_LINESPACE: + { + + SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING ); + aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + if( 100 == ePropL ) + aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; + else + aLineSpacing.SetPropLineSpace(ePropL); + aSet.Put( aLineSpacing ); + } + break; + + case SID_ATTR_PARA_LEFT_TO_RIGHT : + case SID_ATTR_PARA_RIGHT_TO_LEFT : + { + BOOL bSet = TRUE; + int eState = pArgs ? pArgs->GetItemState(nSlot) : SFX_ITEM_DISABLED; + if (pArgs && SFX_ITEM_SET == eState) + bSet = ((const SfxBoolItem&)pArgs->Get(nSlot)).GetValue(); +/* +// toggling of the slots not used anymore + + if(!bSet) + nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot ? + SID_ATTR_PARA_RIGHT_TO_LEFT : + SID_ATTR_PARA_LEFT_TO_RIGHT; +*/ + SfxItemSet aAdjustSet( GetPool(), + RES_PARATR_ADJUST, RES_PARATR_ADJUST ); + GetShell().GetCurAttr(aAdjustSet); + BOOL bChgAdjust = FALSE; + SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, FALSE); + if(eAdjustState >= SFX_ITEM_DEFAULT) + { + int eAdjust = (int)(( const SvxAdjustItem& ) + aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust(); +// bChgAdjust = SVX_ADJUST_CENTER != eAdjust && SVX_ADJUST_BLOCK != eAdjust; + bChgAdjust = (SVX_ADJUST_LEFT == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) || + (SVX_ADJUST_RIGHT == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot); + } + else + bChgAdjust = TRUE; + + SvxFrameDirection eFrmDirection = + (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ? + FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP; + aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) ); + + if (bChgAdjust) + { + SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ? + SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT; + SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST ); + aSet.Put( aAdjust ); + aAdjust.SetWhich(SID_ATTR_PARA_ADJUST); + GetView().GetViewFrame()->GetBindings().SetState( aAdjust ); + // Toggle numbering alignment + const SwNumRule* pCurRule = GetShell().GetCurNumRule(); + if( pCurRule ) + { + SvxNumRule aRule = pCurRule->MakeSvxNumRule(); + + for(USHORT i = 0; i < aRule.GetLevelCount(); i++) + { + SvxNumberFormat aFmt(aRule.GetLevel(i)); + if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust()) + aFmt.SetNumAdjust( SVX_ADJUST_RIGHT ); + + else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust()) + aFmt.SetNumAdjust( SVX_ADJUST_LEFT ); + + aRule.SetLevel(i, aFmt, aRule.Get(i) != 0); + } + // --> OD 2008-02-11 #newlistlevelattrs# + SwNumRule aSetRule( pCurRule->GetName(), + pCurRule->Get( 0 ).GetPositionAndSpaceMode() ); + // <-- + aSetRule.SetSvxRule( aRule, GetShell().GetDoc()); + aSetRule.SetAutoRule( TRUE ); + // --> OD 2008-03-17 #refactorlists# + // no start or continuation of a list - list style is only changed + GetShell().SetCurNumRule( aSetRule, false ); + // <-- + } + } + } + break; + + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } + SwWrtShell& rWrtSh = GetShell(); + SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); + if(pColl && pColl->IsAutoUpdateFmt()) + { + rWrtSh.AutoUpdatePara(pColl, aSet); + } + else + rWrtSh.SetAttr( aSet ); + rReq.Done(); +} + +#endif + + + +void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem *pItem = 0; + + USHORT nSlot = rReq.GetSlot(); + if(pArgs) + pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem); + switch ( nSlot ) + { + case FN_DROP_CHAR_STYLE_NAME: + if( pItem ) + { + String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue(); + SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L); + rSh.GetCurAttr(aSet); + SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP)); + SwCharFmt* pFmt = 0; + if(sCharStyleName.Len()) + pFmt = rSh.FindCharFmtByName( sCharStyleName ); + aDropItem.SetCharFmt( pFmt ); + aSet.Put(aDropItem); + rSh.SetAttr(aSet); + } + break; + case FN_FORMAT_DROPCAPS: + { + if(pItem) + { + rSh.SetAttr(*pItem); + rReq.Done(); + } + else + { + SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, + HINT_END, HINT_END, 0); + rSh.GetCurAttr(aSet); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet, + rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if (pDlg->Execute() == RET_OK) + { + rSh.StartAction(); + rSh.StartUndo( UNDO_START ); + if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,FALSE,&pItem) ) + { + if ( ((SfxStringItem*)pItem)->GetValue().Len() ) + rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue()); + } + rSh.SetAttr(*pDlg->GetOutputItemSet()); + rSh.StartUndo( UNDO_END ); + rSh.EndAction(); + rReq.Done(*pDlg->GetOutputItemSet()); + } + delete pDlg; + } + } + break; + case SID_ATTR_PARA_PAGEBREAK: + if(pItem) + { + rSh.SetAttr( *pItem ); + rReq.Done(); + } + break; + case SID_ATTR_PARA_MODEL: + { + if(pItem) + { + SfxItemSet aCoreSet( GetPool(), + RES_PAGEDESC, RES_PAGEDESC, + SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0); + aCoreSet.Put(*pItem); + SfxToSwPageDescAttr( rSh, aCoreSet); + rSh.SetAttr(aCoreSet); + rReq.Done(); + } + } + break; + + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } +} + + + +void SwTextShell::GetAttrState(SfxItemSet &rSet) +{ + SwWrtShell &rSh = GetShell(); + SfxItemPool& rPool = GetPool(); + SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange); + rSh.GetCurAttr(aCoreSet); // *alle* Textattribute von der Core erfragen + + SfxWhichIter aIter(rSet); + USHORT nSlot = aIter.FirstWhich(); + sal_Bool bFlag = sal_False; + SfxBoolItem aFlagItem; + const SfxPoolItem* pItem = 0; + int eAdjust = -1; // Illegaler Wert, um DONTCARE zu erkennen + SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, FALSE, &pItem); + + if( SFX_ITEM_DEFAULT == eState ) + pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST); + if( SFX_ITEM_DEFAULT <= eState ) + eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust(); + + short nEsc = 0; + eState = aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, FALSE, &pItem); + if( SFX_ITEM_DEFAULT == eState ) + pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT); + if( eState >= SFX_ITEM_DEFAULT ) + nEsc = ((SvxEscapementItem* )pItem)->GetEsc(); + + USHORT nLineSpace = 0; + eState = aCoreSet.GetItemState(RES_PARATR_LINESPACING, FALSE, &pItem); + if( SFX_ITEM_DEFAULT == eState ) + pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING); + if( SFX_ITEM_DEFAULT <= eState && + ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO ) + { + if(SVX_INTER_LINE_SPACE_OFF == + ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule()) + nLineSpace = 100; + else + nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace(); + } + + while (nSlot) + { + switch(nSlot) + { + case FN_SET_SUPER_SCRIPT: + bFlag = 0 < nEsc; + break; + case FN_SET_SUB_SCRIPT: + bFlag = 0 > nEsc; + break; + case SID_ATTR_PARA_ADJUST_LEFT: + if (eAdjust == -1) + { + rSet.InvalidateItem( nSlot ); + nSlot = 0; + } + else + bFlag = SVX_ADJUST_LEFT == eAdjust; + break; + case SID_ATTR_PARA_ADJUST_RIGHT: + if (eAdjust == -1) + { + rSet.InvalidateItem( nSlot ); + nSlot = 0; + } + else + bFlag = SVX_ADJUST_RIGHT == eAdjust; + break; + case SID_ATTR_PARA_ADJUST_CENTER: + if (eAdjust == -1) + { + rSet.InvalidateItem( nSlot ); + nSlot = 0; + } + else + bFlag = SVX_ADJUST_CENTER == eAdjust; + break; + case SID_ATTR_PARA_ADJUST_BLOCK: + { + if (eAdjust == -1) + { + rSet.InvalidateItem( nSlot ); + nSlot = 0; + } + else + { + bFlag = SVX_ADJUST_BLOCK == eAdjust; + USHORT nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell()); + if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & (HTMLMODE_FULL_STYLES|HTMLMODE_FIRSTLINE) )) + { + rSet.DisableItem( nSlot ); + nSlot = 0; + } + } + } + break; + case SID_ATTR_PARA_LINESPACE_10: + bFlag = nLineSpace == 100; + break; + case SID_ATTR_PARA_LINESPACE_15: + bFlag = nLineSpace == 150; + break; + case SID_ATTR_PARA_LINESPACE_20: + bFlag = nLineSpace == 200; + break; + case FN_GROW_FONT_SIZE: + case FN_SHRINK_FONT_SIZE: + { + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, + *rSet.GetPool() ); + aSetItem.GetItemSet().Put( aCoreSet, FALSE ); + if( !aSetItem.GetItemOfScript( rSh.GetScriptType() )) + rSet.DisableItem( nSlot ); + nSlot = 0; + } + break; + case FN_UNDERLINE_DOUBLE: + { + eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE); + if( eState >= SFX_ITEM_DEFAULT ) + { + FontUnderline eUnderline = ((const SvxUnderlineItem&) + aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle(); + rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE)); + } + else + rSet.InvalidateItem(nSlot); + nSlot = 0; + } + break; + case SID_ATTR_PARA_ADJUST: + if (eAdjust == -1) + rSet.InvalidateItem( nSlot ); + else + rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST )); + nSlot = 0; + break; + + case SID_ATTR_PARA_LEFT_TO_RIGHT : + case SID_ATTR_PARA_RIGHT_TO_LEFT : + { + if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() ) + { + rSet.DisableItem( nSlot ); + nSlot = 0; + } + else + { + // is the item set? + USHORT nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell()); + if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) && + aCoreSet.GetItemState( RES_FRAMEDIR, FALSE ) >= SFX_ITEM_DEFAULT) + { + SvxFrameDirection eFrmDir = (SvxFrameDirection) + ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue(); + if (FRMDIR_ENVIRONMENT == eFrmDir) + { + eFrmDir = rSh.IsInRightToLeftText() ? + FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP; + } + bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot && + FRMDIR_HORI_LEFT_TOP == eFrmDir) || + (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot && + FRMDIR_HORI_RIGHT_TOP == eFrmDir); + } + else + { + rSet.InvalidateItem(nSlot); + nSlot = 0; + } + } + } + break; + + case SID_ATTR_CHAR_LANGUAGE: + case SID_ATTR_CHAR_KERNING: + case RES_PARATR_DROP: + { +#if OSL_DEBUG_LEVEL > 1 + const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), TRUE); + rSet.Put(rItem); +#else + rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), TRUE)); +#endif + nSlot = 0; + } + break; + case SID_ATTR_PARA_MODEL: + { + SfxItemSet aTemp(GetPool(), + RES_PAGEDESC,RES_PAGEDESC, + SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL, + 0L); + aTemp.Put(aCoreSet); + ::SwToSfxPageDescAttr(aTemp); + rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL)); + nSlot = 0; + } + break; + case RES_TXTATR_INETFMT: + { + SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); + rSh.GetCurAttr(aSet); +#if OSL_DEBUG_LEVEL > 1 + const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, TRUE); + rSet.Put(rItem); +#else + rSet.Put(aSet.Get( RES_TXTATR_INETFMT, TRUE)); +#endif + nSlot = 0; + } + break; + + default: + // Nichts tun + nSlot = 0; + break; + + } + if( nSlot ) + { + aFlagItem.SetWhich( nSlot ); + aFlagItem.SetValue( bFlag ); + rSet.Put( aFlagItem ); + } + nSlot = aIter.NextWhich(); + } + + rSet.Put(aCoreSet,FALSE); +} + + + diff --git a/sw/source/ui/shells/txtcrsr.cxx b/sw/source/ui/shells/txtcrsr.cxx new file mode 100644 index 000000000000..8a72bb606e59 --- /dev/null +++ b/sw/source/ui/shells/txtcrsr.cxx @@ -0,0 +1,334 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <sfx2/request.hxx> +#include <svl/eitem.hxx> +#ifndef __SBX_SBXVARIABLE_HXX //autogen +#include <basic/sbxvar.hxx> +#endif +#include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> + +#ifndef _VIEW_HXX +#include <view.hxx> +#endif +#include <wrtsh.hxx> +#ifndef _TEXTSH_HXX +#include <textsh.hxx> +#endif +#include <num.hxx> +#include <edtwin.hxx> +#include <crsskip.hxx> + +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#include <globals.h> +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif + +using namespace ::com::sun::star; + +void SwTextShell::ExecBasicMove(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + GetView().GetEditWin().FlushInBuffer(); + const SfxItemSet *pArgs = rReq.GetArgs(); + BOOL bSelect = FALSE; + USHORT nCount = 1; + if(pArgs) + { + const SfxPoolItem *pItem; + if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_MOVE_COUNT, TRUE, &pItem)) + nCount = ((const SfxInt16Item *)pItem)->GetValue(); + if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_MOVE_SELECTION, TRUE, &pItem)) + bSelect = ((const SfxBoolItem *)pItem)->GetValue(); + } + switch(rReq.GetSlot()) + { + case FN_CHAR_LEFT_SEL: rReq.SetSlot( FN_CHAR_LEFT ); bSelect = TRUE; break; + case FN_CHAR_RIGHT_SEL: rReq.SetSlot( FN_CHAR_RIGHT ); bSelect = TRUE; break; + case FN_LINE_UP_SEL: rReq.SetSlot( FN_LINE_UP ); bSelect = TRUE; break; + case FN_LINE_DOWN_SEL: rReq.SetSlot( FN_LINE_DOWN ); bSelect = TRUE; break; + } + + uno::Reference< frame::XDispatchRecorder > xRecorder = + GetView().GetViewFrame()->GetBindings().GetRecorder(); + if ( xRecorder.is() ) + { + rReq.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nCount) ); + rReq.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, bSelect) ); + } + USHORT nSlot = rReq.GetSlot(); + rReq.Done(); + // Get EditWin before calling the move functions (shell change may occur!) + SwEditWin& rTmpEditWin = GetView().GetEditWin(); + for( USHORT i = 0; i < nCount; i++ ) + { + switch(nSlot) + { + case FN_CHAR_LEFT: rSh.Left( CRSR_SKIP_CELLS, bSelect, 1, FALSE, TRUE ); break; + case FN_CHAR_RIGHT: rSh.Right( CRSR_SKIP_CELLS, bSelect, 1, FALSE, TRUE ); break; + case FN_LINE_UP: rSh.Up ( bSelect, 1 ); break; + case FN_LINE_DOWN: rSh.Down ( bSelect, 1 ); break; + default: ASSERT(FALSE, falscher Dispatcher); return; + } + } + + //#i42732# - notify the edit window that from now on we do not use the input language + rTmpEditWin.SetUseInputLanguage( sal_False ); +} + +void SwTextShell::ExecMove(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + SwEditWin& rTmpEditWin = GetView().GetEditWin(); + rTmpEditWin.FlushInBuffer(); + + USHORT nSlot = rReq.GetSlot(); + BOOL bRet = FALSE; + switch ( nSlot ) + { + case FN_START_OF_LINE_SEL: + case FN_START_OF_LINE: bRet = rSh.LeftMargin ( FN_START_OF_LINE_SEL == nSlot, FALSE ); + break; + + case FN_END_OF_LINE_SEL: + case FN_END_OF_LINE: bRet = rSh.RightMargin( FN_END_OF_LINE_SEL == nSlot, FALSE ); + break; + + case FN_START_OF_DOCUMENT_SEL: + case FN_START_OF_DOCUMENT: bRet = rSh.SttDoc ( FN_START_OF_DOCUMENT_SEL == nSlot); + break; + + case FN_END_OF_DOCUMENT_SEL: + case FN_END_OF_DOCUMENT: bRet = rSh.EndDoc( FN_END_OF_DOCUMENT_SEL == nSlot ); + break; + + case FN_SELECT_WORD: bRet = rSh.SelNearestWrd(); break; + + case SID_SELECTALL: bRet = 0 != rSh.SelAll(); break; + default: ASSERT(FALSE, falscher Dispatcher); return; + } + + if ( bRet ) + rReq.Done(); + else + rReq.Ignore(); + + //#i42732# - notify the edit window that from now on we do not use the input language + rTmpEditWin.SetUseInputLanguage( sal_False ); +} + +void SwTextShell::ExecMovePage(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + GetView().GetEditWin().FlushInBuffer(); + + USHORT nSlot = rReq.GetSlot(); + switch( nSlot ) + { + case FN_START_OF_NEXT_PAGE_SEL : + case FN_START_OF_NEXT_PAGE: rSh.SttNxtPg( FN_START_OF_NEXT_PAGE_SEL == nSlot ); break; + + case FN_END_OF_NEXT_PAGE_SEL: + case FN_END_OF_NEXT_PAGE: rSh.EndNxtPg( FN_END_OF_NEXT_PAGE_SEL == nSlot ); break; + + case FN_START_OF_PREV_PAGE_SEL: + case FN_START_OF_PREV_PAGE: rSh.SttPrvPg( FN_START_OF_PREV_PAGE_SEL == nSlot ); break; + + case FN_END_OF_PREV_PAGE_SEL: + case FN_END_OF_PREV_PAGE: rSh.EndPrvPg( FN_END_OF_PREV_PAGE_SEL == nSlot ); break; + + case FN_START_OF_PAGE_SEL: + case FN_START_OF_PAGE: rSh.SttPg ( FN_START_OF_PAGE_SEL == nSlot ); break; + + case FN_END_OF_PAGE_SEL: + case FN_END_OF_PAGE: rSh.EndPg ( FN_END_OF_PAGE_SEL == nSlot ); break; + default: ASSERT(FALSE, falscher Dispatcher); return; + } + rReq.Done(); +} + + +void SwTextShell::ExecMoveCol(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + switch ( rReq.GetSlot() ) + { + case FN_START_OF_COLUMN: rSh.StartOfColumn ( FALSE ); break; + case FN_END_OF_COLUMN: rSh.EndOfColumn ( FALSE ); break; + case FN_START_OF_NEXT_COLUMN: rSh.StartOfNextColumn( FALSE ) ; break; + case FN_END_OF_NEXT_COLUMN: rSh.EndOfNextColumn ( FALSE ); break; + case FN_START_OF_PREV_COLUMN: rSh.StartOfPrevColumn( FALSE ); break; + case FN_END_OF_PREV_COLUMN: rSh.EndOfPrevColumn ( FALSE ); break; + default: ASSERT(FALSE, falscher Dispatcher); return; + } + rReq.Done(); +} + +void SwTextShell::ExecMoveLingu(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + GetView().GetEditWin().FlushInBuffer(); + + USHORT nSlot = rReq.GetSlot(); + BOOL bRet = FALSE; + switch ( nSlot ) + { + case FN_NEXT_WORD_SEL: + case FN_NEXT_WORD: bRet = rSh.NxtWrd( FN_NEXT_WORD_SEL == nSlot ); + break; + + case FN_START_OF_PARA_SEL: + case FN_START_OF_PARA: bRet = rSh.SttPara( FN_START_OF_PARA_SEL == nSlot ); + break; + + case FN_END_OF_PARA_SEL: + case FN_END_OF_PARA: bRet = rSh.EndPara( FN_END_OF_PARA_SEL == nSlot ); + break; + + case FN_PREV_WORD_SEL: + case FN_PREV_WORD: bRet = rSh.PrvWrd( FN_PREV_WORD_SEL == nSlot ); + break; + + case FN_NEXT_SENT_SEL: + case FN_NEXT_SENT: bRet = rSh.FwdSentence( FN_NEXT_SENT_SEL == nSlot ); + break; + + case FN_PREV_SENT_SEL: + case FN_PREV_SENT: bRet = rSh.BwdSentence( FN_PREV_SENT_SEL == nSlot ); + break; + + case FN_NEXT_PARA: bRet = rSh.FwdPara ( FALSE ); + break; + + case FN_PREV_PARA: bRet = rSh.BwdPara ( FALSE ); + break; + default: ASSERT(FALSE, falscher Dispatcher); return; + } + rReq.Done(); +} + +void SwTextShell::ExecMoveMisc(SfxRequest &rReq) +{ + SwWrtShell &rSh = GetShell(); + USHORT nSlot = rReq.GetSlot(); + BOOL bSetRetVal = TRUE, bRet = TRUE; + switch ( nSlot ) + { + case FN_CNTNT_TO_NEXT_FRAME: + bRet = rSh.GotoObj(TRUE, GOTOOBJ_GOTO_ANY); + if(bRet) + { + rSh.HideCrsr(); + rSh.EnterSelFrmMode(); + } + break; + case FN_NEXT_FOOTNOTE: + rSh.MoveCrsr(); + bRet = rSh.GotoNextFtnAnchor(); + break; + case FN_PREV_FOOTNOTE: + rSh.MoveCrsr(); + bRet = rSh.GotoPrevFtnAnchor(); + break; + case FN_TO_HEADER: + rSh.MoveCrsr(); + if ( FRMTYPE_HEADER & rSh.GetFrmType(0,FALSE) ) + rSh.SttPg(); + else + rSh.GotoHeaderTxt(); + bSetRetVal = FALSE; + break; + case FN_TO_FOOTER: + rSh.MoveCrsr(); + if ( FRMTYPE_FOOTER & rSh.GetFrmType(0,FALSE) ) + rSh.EndPg(); + else + rSh.GotoFooterTxt(); + bSetRetVal = FALSE; + break; + case FN_FOOTNOTE_TO_ANCHOR: + rSh.MoveCrsr(); + if ( FRMTYPE_FOOTNOTE & rSh.GetFrmType(0,FALSE) ) + rSh.GotoFtnAnchor(); + else + rSh.GotoFtnTxt(); + bSetRetVal = FALSE; + break; + case FN_TO_FOOTNOTE_AREA : + rSh.GotoFtnTxt(); + break; + case FN_PREV_TABLE: + bRet = rSh.MoveTable( fnTablePrev, fnTableStart); + break; + case FN_NEXT_TABLE: + bRet = rSh.MoveTable(fnTableNext, fnTableStart); + break; + case FN_GOTO_NEXT_REGION : + bRet = rSh.MoveRegion(fnRegionNext, fnRegionStart); + break; + case FN_GOTO_PREV_REGION : + bRet = rSh.MoveRegion(fnRegionPrev, fnRegionStart); + break; + + case FN_NEXT_TOXMARK: + bRet = rSh.GotoNxtPrvTOXMark( TRUE ); + break; + case FN_PREV_TOXMARK: + bRet = rSh.GotoNxtPrvTOXMark( FALSE ); + break; + case FN_NEXT_TBLFML: + bRet = rSh.GotoNxtPrvTblFormula( TRUE, FALSE ); + break; + case FN_PREV_TBLFML: + bRet = rSh.GotoNxtPrvTblFormula( FALSE, FALSE ); + break; + case FN_NEXT_TBLFML_ERR: + bRet = rSh.GotoNxtPrvTblFormula( TRUE, TRUE ); + break; + case FN_PREV_TBLFML_ERR: + bRet = rSh.GotoNxtPrvTblFormula( FALSE, TRUE ); + break; + + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } + + if( bSetRetVal ) + rReq.SetReturnValue(SfxBoolItem( nSlot, bRet )); + rReq.Done(); + +} + diff --git a/sw/source/ui/shells/txtnum.cxx b/sw/source/ui/shells/txtnum.cxx new file mode 100644 index 000000000000..0e89b96a8d6a --- /dev/null +++ b/sw/source/ui/shells/txtnum.cxx @@ -0,0 +1,251 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <hintids.hxx> +#ifndef _MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#include <sfx2/request.hxx> +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> +#include <editeng/numitem.hxx> +#include <editeng/brshitem.hxx> +#include <numrule.hxx> + +#include "cmdid.h" +#include "wrtsh.hxx" +#include "view.hxx" +#include "viewopt.hxx" +#include "wdocsh.hxx" +#include "textsh.hxx" +#include "uiitems.hxx" +#include "swabstdlg.hxx" +#include <globals.hrc> +#include <sfx2/tabdlg.hxx> + +void SwTextShell::ExecEnterNum(SfxRequest &rReq) +{ + //wg. Aufzeichnung schon vor dem evtl. Shellwechsel + switch(rReq.GetSlot()) + { + case FN_NUM_NUMBERING_ON: + { + SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , sal_False ); + BOOL bMode = !GetShell().HasNumber(); // #i29560# + if ( pItem ) + bMode = pItem->GetValue(); + else + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) ); + + if ( bMode != (GetShell().HasNumber()) ) // #i29560# + { + rReq.Done(); + if( bMode ) + GetShell().NumOn(); + else + GetShell().NumOrBulletOff(); // #i29560# + } + } + break; + case FN_NUM_BULLET_ON: + { + SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , sal_False ); + BOOL bMode = !GetShell().HasBullet(); // #i29560# + if ( pItem ) + bMode = pItem->GetValue(); + else + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) ); + + if ( bMode != (GetShell().HasBullet()) ) // #i29560# + { + rReq.Done(); + if( bMode ) + GetShell().BulletOn(); + else + GetShell().NumOrBulletOff(); // #i29560# + } + } + break; + case FN_NUMBER_BULLETS: + { + // --> OD 2008-02-29 #refactorlists# +// // per default TRUE, damit die Schleife im Dialog richtig arbeitet! +// BOOL bHasChild = TRUE; + // <-- + SfxItemSet aSet(GetPool(), + SID_HTML_MODE, SID_HTML_MODE, + SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, + 0 ); + SwDocShell* pDocSh = GetView().GetDocShell(); + BOOL bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh); + const SwNumRule* pCurRule = GetShell().GetCurNumRule(); + if( pCurRule ) + { + SvxNumRule aRule = pCurRule->MakeSvxNumRule(); + + //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN) + for(USHORT i = 0; i < aRule.GetLevelCount(); i++) + { + SvxNumberFormat aFmt(aRule.GetLevel(i)); + if(SVX_NUM_BITMAP == aFmt.GetNumberingType()) + { + const SvxBrushItem* pBrush = aFmt.GetBrush(); + const String* pLinkStr; + if(pBrush && + 0 != (pLinkStr = pBrush->GetGraphicLink()) && + pLinkStr->Len()) + aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN)); + aRule.SetLevel(i, aFmt, aRule.Get(i) != 0); + } + } + if(bHtml) + aRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, FALSE); + + aSet.Put(SvxNumBulletItem(aRule)); + // --> OD 2008-02-29 #refactorlists# - removed <bHasChild> + ASSERT( GetShell().GetNumLevel() < MAXLEVEL, + "<SwTextShell::ExecEnterNum()> - numbered node without valid list level. Serious defect -> please inform OD." ); + USHORT nLevel = GetShell().GetNumLevel(); + // <-- + if( nLevel < MAXLEVEL ) + { + nLevel = 1<<nLevel; + aSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel )); + } + } + else + { + // --> OD 2008-02-11 #newlistlevelattrs# + SwNumRule aRule( GetShell().GetUniqueNumRuleName(), + // --> OD 2008-06-06 #i89178# + numfunc::GetDefaultPositionAndSpaceMode() ); + // <-- + // <-- + SvxNumRule aSvxRule = aRule.MakeSvxNumRule(); + const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 ); + + if( bHtml || bRightToLeft ) + { + for( BYTE n = 0; n < MAXLEVEL; ++n ) + { + SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) ); + if ( n && bHtml ) + { + // 1/2" fuer HTML + aFmt.SetLSpace(720); + aFmt.SetAbsLSpace(n * 720); + } + // --> FME 2005-01-21 #i38904# Default alignment for + // numbering/bullet should be rtl in rtl paragraph: + if ( bRightToLeft ) + { + aFmt.SetNumAdjust( SVX_ADJUST_RIGHT ); + } + // <-- + aSvxRule.SetLevel( n, aFmt, FALSE ); + } + aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, FALSE); + } + aSet.Put(SvxNumBulletItem(aSvxRule)); + } + + aSet.Put( SfxBoolItem( SID_PARAM_NUM_PRESET,FALSE )); + + // vor dem Dialog wird der HtmlMode an der DocShell versenkt + pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh))); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET, + GetView().GetWindow(), &aSet, GetShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + USHORT nRet = pDlg->Execute(); + const SfxPoolItem* pItem; + if( RET_OK == nRet ) + { + if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, FALSE, &pItem )) + { + rReq.AppendItem(*pItem); + rReq.Done(); + SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule(); + pSetRule->UnLinkGraphics(); + // --> OD 2008-02-11 #newlistlevelattrs# + SwNumRule aSetRule( pCurRule + ? pCurRule->GetName() + : GetShell().GetUniqueNumRuleName(), + // --> OD 2008-06-06 #i89178# + numfunc::GetDefaultPositionAndSpaceMode() ); + // <-- + // <-- + aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc()); + aSetRule.SetAutoRule( TRUE ); + // --> OD 2008-03-17 #refactorlists# + // No start of new list, if an existing list style is edited. + // Otherwise start a new list. + const bool bCreateList = (pCurRule == 0); + GetShell().SetCurNumRule( aSetRule, bCreateList ); + // <-- + } + // wenn der Dialog mit OK verlassen wurde, aber nichts ausgewaehlt + // wurde dann muss die Numerierung zumindest eingeschaltet werden, + // wenn sie das noch nicht ist + else if( !pCurRule && SFX_ITEM_SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, FALSE, &pItem )) + { + rReq.AppendItem( *pItem ); + rReq.Done(); + SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule(); + // --> OD 2008-02-11 #newlistlevelattrs# + SwNumRule aSetRule( GetShell().GetUniqueNumRuleName(), + // --> OD 2008-06-06 #i89178# + numfunc::GetDefaultPositionAndSpaceMode() ); + // <-- + // <-- + aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc()); + aSetRule.SetAutoRule( TRUE ); + // --> OD 2008-03-17 #refactorlists# + // start new list + GetShell().SetCurNumRule( aSetRule, true ); + // <-- + } + } + else if(RET_USER == nRet) + GetShell().DelNumRules(); + + delete pDlg; + } + break; + default: + ASSERT(FALSE, falscher Dispatcher); + return; + } +} + + |