2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* $RCSfile: fubullet.cxx,v $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-11-16 08:20:37 +00:00
|
|
|
* $Revision: 1.7 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-11-16 08:20:37 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2005-11-16 09:20:37 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* This library 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 for more details.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 03:34:15 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
2004-01-20 09:56:22 +00:00
|
|
|
#include "fubullet.hxx"
|
|
|
|
|
2005-11-16 08:20:37 +00:00
|
|
|
#ifndef _BINDING_HXX //autogen
|
|
|
|
#include <sfx2/bindings.hxx>
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _EEITEM_HXX //autogen
|
|
|
|
#include <svx/eeitem.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXPOOLITEM_HXX //autogen
|
|
|
|
#include <svtools/poolitem.hxx>
|
|
|
|
#endif
|
|
|
|
#define ITEMID_FONT EE_CHAR_FONTINFO
|
|
|
|
#include <svx/fontitem.hxx>
|
|
|
|
|
2004-01-20 09:56:22 +00:00
|
|
|
#ifndef SD_OUTLINE_VIEW_SHELL_HXX
|
|
|
|
#include "OutlineViewShell.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_DRAW_VIEW_SHELL_HXX
|
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_WINDOW_HXX
|
|
|
|
#include "Window.hxx"
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "drawdoc.hxx"
|
|
|
|
#include "strings.hrc"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
|
|
|
|
#ifndef _SVDOUTL_HXX //autogen
|
|
|
|
#include <svx/svdoutl.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_MSGBOX_HXX //autogen
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_CHARMAP_HXX //autogen
|
|
|
|
#include <svx/charmap.hxx>
|
|
|
|
#endif
|
2005-11-16 08:20:37 +00:00
|
|
|
#ifndef _SFXREQUEST_HXX //autogen
|
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVTOOLS_CTLOPTIONS_HXX
|
|
|
|
#include <svtools/ctloptions.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifdef IRIX
|
|
|
|
#ifndef _SBXCLASS_HXX
|
2005-04-13 08:36:21 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2004-02-04 09:04:37 +00:00
|
|
|
#include <svx/svxdlg.hxx> //CHINA001
|
|
|
|
#include <svx/dialogs.hrc> //CHINA001
|
2005-11-16 08:20:37 +00:00
|
|
|
#ifndef SD_DRAW_VIEW_HXX
|
|
|
|
#include "drawview.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "app.hrc"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-01-20 09:56:22 +00:00
|
|
|
namespace sd {
|
|
|
|
|
2005-11-16 08:20:37 +00:00
|
|
|
const sal_Unicode CHAR_HARDBLANK = ((sal_Unicode)0x00A0);
|
|
|
|
const sal_Unicode CHAR_HARDHYPHEN = ((sal_Unicode)0x2011);
|
|
|
|
const sal_Unicode CHAR_SOFTHYPHEN = ((sal_Unicode)0x00AD);
|
|
|
|
const sal_Unicode CHAR_RLM = ((sal_Unicode)0x200F);
|
|
|
|
const sal_Unicode CHAR_LRM = ((sal_Unicode)0x200E);
|
|
|
|
const sal_Unicode CHAR_ZWSP = ((sal_Unicode)0x200B);
|
|
|
|
const sal_Unicode CHAR_ZWNBSP = ((sal_Unicode)0x2060);
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
TYPEINIT1( FuBullet, FuPoor );
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 09:56:22 +00:00
|
|
|
FuBullet::FuBullet (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
2005-11-16 08:20:37 +00:00
|
|
|
if( rReq.GetSlot() == SID_BULLET )
|
|
|
|
InsertSpecialCharacter();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Unicode cMark = 0;
|
|
|
|
switch( rReq.GetSlot() )
|
|
|
|
{
|
|
|
|
case FN_INSERT_SOFT_HYPHEN: cMark = CHAR_SOFTHYPHEN ; break;
|
|
|
|
case FN_INSERT_HARDHYPHEN: cMark = CHAR_HARDHYPHEN ; break;
|
|
|
|
case FN_INSERT_HARD_SPACE: cMark = CHAR_HARDBLANK ; break;
|
|
|
|
case SID_INSERT_RLM : cMark = CHAR_RLM ; break;
|
|
|
|
case SID_INSERT_LRM : cMark = CHAR_LRM ; break;
|
|
|
|
case SID_INSERT_ZWSP : cMark = CHAR_ZWSP ; break;
|
|
|
|
case SID_INSERT_ZWNBSP: cMark = CHAR_ZWNBSP; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_ASSERT( cMark != 0, "FuBullet::FuBullet(), illegal slot used!" );
|
|
|
|
|
|
|
|
if( cMark )
|
|
|
|
InsertFormattingMark( cMark );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuBullet::InsertFormattingMark( sal_Unicode cMark )
|
|
|
|
{
|
|
|
|
OutlinerView* pOV = NULL;
|
|
|
|
::Outliner* pOL = NULL;
|
|
|
|
|
|
|
|
// depending on ViewShell set Outliner and OutlinerView
|
|
|
|
if (pViewShell->ISA(DrawViewShell))
|
|
|
|
{
|
|
|
|
pOV = pView->GetTextEditOutlinerView();
|
|
|
|
if (pOV)
|
|
|
|
pOL = pView->GetTextEditOutliner();
|
|
|
|
}
|
|
|
|
else if (pViewShell->ISA(OutlineViewShell))
|
|
|
|
{
|
|
|
|
pOL = static_cast<OutlineView*>(pView)->GetOutliner();
|
|
|
|
pOV = static_cast<OutlineView*>(pView)->GetViewByWindow(
|
|
|
|
pViewShell->GetActiveWindow());
|
|
|
|
}
|
|
|
|
|
|
|
|
// insert string
|
|
|
|
if(pOV && pOL)
|
|
|
|
{
|
|
|
|
// prevent flickering
|
|
|
|
pOV->HideCursor();
|
|
|
|
pOL->SetUpdateMode(FALSE);
|
|
|
|
|
|
|
|
// remove old selected text
|
|
|
|
String aEmptyStr;
|
|
|
|
pOV->InsertText( aEmptyStr );
|
|
|
|
|
|
|
|
// prepare undo
|
|
|
|
SfxUndoManager& rUndoMgr = pOL->GetUndoManager();
|
|
|
|
rUndoMgr.EnterListAction(String(SdResId(STR_UNDO_INSERT_SPECCHAR)),
|
|
|
|
aEmptyStr );
|
|
|
|
|
|
|
|
// insert given text
|
|
|
|
String aStr( cMark );
|
|
|
|
pOV->InsertText( cMark, TRUE);
|
|
|
|
|
|
|
|
ESelection aSel = pOV->GetSelection();
|
|
|
|
aSel.nStartPara = aSel.nEndPara;
|
|
|
|
aSel.nStartPos = aSel.nEndPos;
|
|
|
|
pOV->SetSelection(aSel);
|
|
|
|
|
|
|
|
rUndoMgr.LeaveListAction();
|
|
|
|
|
|
|
|
// restart repainting
|
|
|
|
pOL->SetUpdateMode(TRUE);
|
|
|
|
pOV->ShowCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuBullet::InsertSpecialCharacter()
|
|
|
|
{
|
2004-02-04 09:04:37 +00:00
|
|
|
//CHINA001 SvxCharacterMap* pDlg = new SvxCharacterMap( NULL, FALSE );
|
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
|
|
|
DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
|
|
|
|
AbstractSvxCharacterMap* pDlg = pFact->CreateSvxCharacterMap( NULL, ResId(RID_SVXDLG_CHARMAP), FALSE );
|
|
|
|
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SfxItemSet aFontAttr( pDoc->GetPool() );
|
|
|
|
pView->GetAttributes( aFontAttr );
|
|
|
|
const SvxFontItem* pFontItem = (const SvxFontItem*)aFontAttr.GetItem( SID_ATTR_CHAR_FONT );
|
|
|
|
if( pFontItem )
|
|
|
|
{
|
|
|
|
Font aCurrentFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size( 1, 1 ) );
|
|
|
|
pDlg->SetFont( aCurrentFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wenn Zeichen selektiert ist kann es angezeigt werden
|
|
|
|
// pDLg->SetFont( );
|
|
|
|
// pDlg->SetChar( );
|
|
|
|
USHORT nResult = pDlg->Execute();
|
|
|
|
|
|
|
|
//char c;
|
|
|
|
String aString;
|
|
|
|
|
|
|
|
Font aFont;
|
|
|
|
|
|
|
|
if( nResult == RET_OK )
|
|
|
|
{
|
|
|
|
aFont = pDlg->GetCharFont();
|
|
|
|
aString = pDlg->GetCharacters();
|
|
|
|
}
|
|
|
|
delete( pDlg );
|
|
|
|
|
|
|
|
if( nResult == RET_OK )
|
|
|
|
{
|
|
|
|
OutlinerView* pOV = NULL;
|
2004-01-20 09:56:22 +00:00
|
|
|
::Outliner* pOL = NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// je nach ViewShell Outliner und OutlinerView bestimmen
|
2005-11-16 08:20:37 +00:00
|
|
|
if (pViewShell->ISA(DrawViewShell))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pOV = pView->GetTextEditOutlinerView();
|
|
|
|
if (pOV)
|
|
|
|
{
|
|
|
|
pOL = pView->GetTextEditOutliner();
|
|
|
|
}
|
|
|
|
}
|
2005-11-16 08:20:37 +00:00
|
|
|
else if (pViewShell->ISA(OutlineViewShell))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-01-20 09:56:22 +00:00
|
|
|
pOL = static_cast<OutlineView*>(pView)->GetOutliner();
|
|
|
|
pOV = static_cast<OutlineView*>(pView)->GetViewByWindow(
|
|
|
|
pViewShell->GetActiveWindow());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sonderzeichen einfuegen
|
|
|
|
if (pOV)
|
|
|
|
{
|
|
|
|
String aEmptyStr;
|
|
|
|
// nicht flackern
|
|
|
|
pOV->HideCursor();
|
|
|
|
pOL->SetUpdateMode(FALSE);
|
|
|
|
|
|
|
|
// alte Attributierung merken;
|
|
|
|
// dazu vorher selektierten Bereich loeschen, denn der muss eh weg
|
|
|
|
// und so gibt es immer eine eindeutige Attributierung (und da es
|
|
|
|
// kein DeleteSelected() an der OutlinerView gibt, wird durch
|
|
|
|
// Einfuegen eines Leerstrings geloescht)
|
|
|
|
pOV->InsertText( aEmptyStr );
|
|
|
|
|
|
|
|
SfxItemSet aOldSet( pDoc->GetPool(), ITEMID_FONT, ITEMID_FONT, 0 );
|
|
|
|
aOldSet.Put( pOV->GetAttribs() );
|
|
|
|
|
|
|
|
SfxUndoManager& rUndoMgr = pOL->GetUndoManager();
|
|
|
|
rUndoMgr.EnterListAction(String(SdResId(STR_UNDO_INSERT_SPECCHAR)),
|
|
|
|
aEmptyStr );
|
|
|
|
pOV->InsertText(aString, TRUE);
|
|
|
|
|
|
|
|
// attributieren (Font setzen)
|
|
|
|
SfxItemSet aSet(pOL->GetEmptyItemSet());
|
|
|
|
SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(),
|
|
|
|
aFont.GetStyleName(), aFont.GetPitch(),
|
|
|
|
aFont.GetCharSet());
|
|
|
|
aSet.Put(aFontItem);
|
2001-10-25 07:00:17 +00:00
|
|
|
aSet.Put(aFontItem, EE_CHAR_FONTINFO_CJK);
|
|
|
|
aSet.Put(aFontItem, EE_CHAR_FONTINFO_CTL);
|
2000-09-18 16:07:07 +00:00
|
|
|
pOV->SetAttribs(aSet);
|
|
|
|
|
|
|
|
ESelection aSel = pOV->GetSelection();
|
|
|
|
aSel.nStartPara = aSel.nEndPara;
|
|
|
|
aSel.nStartPos = aSel.nEndPos;
|
|
|
|
pOV->SetSelection(aSel);
|
|
|
|
|
|
|
|
// nicht mit Sonderzeichenattributierung weiterschreiben
|
|
|
|
pOV->GetOutliner()->QuickSetAttribs(aOldSet, aSel);
|
|
|
|
|
|
|
|
rUndoMgr.LeaveListAction();
|
|
|
|
|
|
|
|
// ab jetzt wieder anzeigen
|
|
|
|
pOL->SetUpdateMode(TRUE);
|
|
|
|
pOV->ShowCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-16 08:20:37 +00:00
|
|
|
void FuBullet::GetSlotState( SfxItemSet& rSet, ViewShell* pViewShell, SfxViewFrame* pViewFrame )
|
|
|
|
{
|
|
|
|
if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BULLET ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( FN_INSERT_SOFT_HYPHEN ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( FN_INSERT_HARDHYPHEN ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( FN_INSERT_HARD_SPACE ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_RLM ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_LRM ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_ZWNBSP ) ||
|
|
|
|
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_ZWSP ))
|
|
|
|
{
|
|
|
|
::sd::View* pView = pViewShell ? pViewShell->GetView() : 0;
|
|
|
|
OutlinerView* pOLV = pView ? pView->GetTextEditOutlinerView() : 0;
|
|
|
|
|
|
|
|
const bool bTextEdit = pOLV;
|
|
|
|
|
|
|
|
SvtCTLOptions aCTLOptions;
|
|
|
|
const sal_Bool bCtlEnabled = aCTLOptions.IsCTLFontEnabled();
|
|
|
|
|
|
|
|
if(!bTextEdit )
|
|
|
|
{
|
|
|
|
rSet.DisableItem(SID_BULLET);
|
|
|
|
rSet.DisableItem(FN_INSERT_SOFT_HYPHEN);
|
|
|
|
rSet.DisableItem(FN_INSERT_HARDHYPHEN);
|
|
|
|
rSet.DisableItem(FN_INSERT_HARD_SPACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!bTextEdit || !bCtlEnabled )
|
|
|
|
{
|
|
|
|
rSet.DisableItem(SID_INSERT_RLM);
|
|
|
|
rSet.DisableItem(SID_INSERT_LRM);
|
|
|
|
rSet.DisableItem(SID_INSERT_ZWNBSP);
|
|
|
|
rSet.DisableItem(SID_INSERT_ZWSP);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pViewFrame )
|
|
|
|
{
|
|
|
|
SfxBindings& rBindings = pViewFrame->GetBindings();
|
|
|
|
|
|
|
|
rBindings.SetVisibleState( SID_INSERT_RLM, bCtlEnabled );
|
|
|
|
rBindings.SetVisibleState( SID_INSERT_LRM, bCtlEnabled );
|
|
|
|
rBindings.SetVisibleState( SID_INSERT_ZWNBSP, bCtlEnabled );
|
|
|
|
rBindings.SetVisibleState( SID_INSERT_ZWSP, bCtlEnabled );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-01-20 09:56:22 +00:00
|
|
|
} // end of namespace sd
|