1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chardlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
39 #include <hintids.hxx>
41 #ifndef _MSGBOX_HXX //autogen
42 #include <vcl/msgbox.hxx>
44 #include <svtools/urihelper.hxx>
45 #include <svtools/stritem.hxx>
46 #include <svx/flstitem.hxx>
47 #include <svx/htmlmode.hxx>
48 #include <svtools/cjkoptions.hxx>
56 #include <swtypes.hxx>
66 #include <fmtinfmt.hxx>
67 #include <macassgn.hxx>
69 #include <chrdlg.hxx> // der Dialog
71 #include <swmodule.hxx>
72 #include <poolfmt.hxx>
75 #include <globals.hrc>
81 #include <chardlg.hrc>
83 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
84 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
85 #include <SwStyleNameMapper.hxx>
86 #include <sfx2/filedlghelper.hxx>
87 #include <sfx2/viewfrm.hxx>
89 #include <svx/svxdlg.hxx>
90 #include <svx/svxids.hrc>
91 #include <svx/flagsdef.hxx>
92 #include <svx/dialogs.hrc>
94 using namespace ::com::sun::star::ui::dialogs
;
95 using namespace ::com::sun::star::lang
;
96 using namespace ::com::sun::star::uno
;
97 using namespace ::sfx2
;
99 /*--------------------------------------------------------------------
100 Beschreibung: Der Traeger des Dialoges
101 --------------------------------------------------------------------*/
104 SwCharDlg::SwCharDlg(Window
* pParent
, SwView
& rVw
, const SfxItemSet
& rCoreSet
,
105 const String
* pStr
, BOOL bIsDrwTxtDlg
) :
106 SfxTabDialog(pParent
, SW_RES(DLG_CHAR
), &rCoreSet
, pStr
!= 0),
108 bIsDrwTxtMode(bIsDrwTxtDlg
)
112 // bspFonr fuer beide Bsp-TabPages
116 String
aTmp( GetText() );
117 aTmp
+= SW_RESSTR(STR_TEXTCOLL_HEADER
);
122 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
123 DBG_ASSERT(pFact
, "Dialogdiet fail!");
124 AddTabPage(TP_CHAR_STD
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME
), 0 );
125 AddTabPage(TP_CHAR_EXT
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS
), 0 );
126 AddTabPage(TP_CHAR_POS
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION
), 0 );
127 AddTabPage(TP_CHAR_TWOLN
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES
), 0 );
128 AddTabPage(TP_CHAR_URL
, SwCharURLPage::Create
, 0);
129 AddTabPage(TP_BACKGROUND
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), 0 );
131 SvtCJKOptions aCJKOptions
;
134 RemoveTabPage( TP_CHAR_URL
);
135 RemoveTabPage( TP_BACKGROUND
);
136 RemoveTabPage( TP_CHAR_TWOLN
);
138 else if(!aCJKOptions
.IsDoubleLinesEnabled())
139 RemoveTabPage( TP_CHAR_TWOLN
);
141 /*--------------------------------------------------------------------
143 --------------------------------------------------------------------*/
146 SwCharDlg::~SwCharDlg()
150 /*--------------------------------------------------------------------
151 Beschreibung: FontList setzen
152 --------------------------------------------------------------------*/
156 void SwCharDlg::PageCreated( USHORT nId
, SfxTabPage
&rPage
)
158 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
163 SvxFontListItem
aFontListItem( *( (SvxFontListItem
*)
164 ( rView
.GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST
) ) ) );
165 aSet
.Put (SvxFontListItem( aFontListItem
.GetFontList(), SID_ATTR_CHAR_FONTLIST
));
167 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
,SVX_PREVIEW_CHARACTER
));
168 rPage
.PageCreated(aSet
);
173 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_CASEMAP
));
177 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
,SVX_PREVIEW_CHARACTER
|SVX_ENABLE_FLASH
));
179 rPage
.PageCreated(aSet
);
182 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
,SVX_PREVIEW_CHARACTER
));
183 rPage
.PageCreated(aSet
);
186 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
,SVX_PREVIEW_CHARACTER
));
187 rPage
.PageCreated(aSet
);
192 /*-----------------14.08.96 11.28-------------------
194 --------------------------------------------------*/
196 SwCharURLPage::SwCharURLPage( Window
* pParent
,
197 const SfxItemSet
& rCoreSet
) :
198 SfxTabPage( pParent
, SW_RES( TP_CHAR_URL
), rCoreSet
),
199 aURLFL ( this, SW_RES(FL_URL
)),
201 aURLFT( this, SW_RES(FT_URL
)),
202 aURLED( this, SW_RES(ED_URL
)),
203 aTextFT( this, SW_RES(FT_TEXT
)),
204 aTextED( this, SW_RES(ED_TEXT
)),
205 aNameFT( this, SW_RES(FT_NAME
)),
206 aNameED( this, SW_RES(ED_NAME
)),
207 aTargetFrmFT( this, SW_RES(FT_TARGET
)),
208 aTargetFrmLB( this, SW_RES(LB_TARGET
)),
209 aURLPB( this, SW_RES(PB_URL
)),
210 aEventPB( this, SW_RES(PB_EVENT
)),
211 aStyleFL( this, SW_RES(FL_STYLE
)),
212 aVisitedFT( this, SW_RES(FT_VISITED
)),
213 aVisitedLB( this, SW_RES(LB_VISITED
)),
214 aNotVisitedFT( this, SW_RES(FT_NOT_VISITED
)),
215 aNotVisitedLB( this, SW_RES(LB_NOT_VISITED
)),
222 const SfxPoolItem
* pItem
;
223 SfxObjectShell
* pShell
;
224 if(SFX_ITEM_SET
== rCoreSet
.GetItemState(SID_HTML_MODE
, FALSE
, &pItem
) ||
225 ( 0 != ( pShell
= SfxObjectShell::Current()) &&
226 0 != (pItem
= pShell
->GetItem(SID_HTML_MODE
))))
228 USHORT nHtmlMode
= ((const SfxUInt16Item
*)pItem
)->GetValue();
229 if(HTMLMODE_ON
& nHtmlMode
)
234 aNotVisitedFT
.Hide();
235 aNotVisitedLB
.Hide();
239 aURLPB
.SetClickHdl (LINK( this, SwCharURLPage
, InsertFileHdl
));
240 aEventPB
.SetClickHdl(LINK( this, SwCharURLPage
, EventHdl
));
242 SwView
*pView
= ::GetActiveView();
243 ::FillCharStyleListBox(aVisitedLB
, pView
->GetDocShell());
244 ::FillCharStyleListBox(aNotVisitedLB
, pView
->GetDocShell());
246 TargetList
* pList
= new TargetList
;
247 const SfxFrame
* pFrame
= pView
->GetViewFrame()->GetTopFrame();
248 pFrame
->GetTargetList(*pList
);
249 USHORT nCount
= (USHORT
)pList
->Count();
254 for ( i
= 0; i
< nCount
; i
++ )
256 aTargetFrmLB
.InsertEntry(*pList
->GetObject(i
));
258 for ( i
= nCount
; i
; i
-- )
260 delete pList
->GetObject( i
- 1 );
268 /*-----------------15.08.96 09.04-------------------
270 --------------------------------------------------*/
272 SwCharURLPage::~SwCharURLPage()
277 /*-----------------14.08.96 11.31-------------------
279 --------------------------------------------------*/
281 void SwCharURLPage::Reset(const SfxItemSet
& rSet
)
283 const SfxPoolItem
* pItem
;
284 if(SFX_ITEM_SET
== rSet
.GetItemState(RES_TXTATR_INETFMT
, FALSE
, &pItem
))
286 const SwFmtINetFmt
* pINetFmt
= (const SwFmtINetFmt
*)pItem
;
287 aURLED
.SetText( INetURLObject::decode( pINetFmt
->GetValue(),
289 INetURLObject::DECODE_UNAMBIGUOUS
,
290 RTL_TEXTENCODING_UTF8
));
292 aNameED
.SetText(pINetFmt
->GetName());
293 String sEntry
= pINetFmt
->GetVisitedFmt();
295 SwStyleNameMapper::FillUIName( RES_POOLCHR_INET_VISIT
, sEntry
);
296 aVisitedLB
.SelectEntry(sEntry
);
297 sEntry
= pINetFmt
->GetINetFmt();
299 SwStyleNameMapper::FillUIName( RES_POOLCHR_INET_NORMAL
, sEntry
);
300 aNotVisitedLB
.SelectEntry(sEntry
);
302 aTargetFrmLB
.SetText(pINetFmt
->GetTargetFrame());
303 aVisitedLB
. SaveValue();
304 aNotVisitedLB
.SaveValue();
305 aTargetFrmLB
. SaveValue();
306 pINetItem
= new SvxMacroItem(FN_INET_FIELD_MACRO
);
308 if( pINetFmt
->GetMacroTbl() )
309 pINetItem
->SetMacroTable( *pINetFmt
->GetMacroTbl() );
311 if(SFX_ITEM_SET
== rSet
.GetItemState(FN_PARAM_SELECTION
, FALSE
, &pItem
))
313 aTextED
.SetText(((const SfxStringItem
*)pItem
)->GetValue());
314 aTextFT
.Enable( FALSE
);
315 aTextED
.Enable( FALSE
);
319 /*-----------------14.08.96 11.32-------------------
321 --------------------------------------------------*/
323 BOOL
SwCharURLPage::FillItemSet(SfxItemSet
& rSet
)
325 ::rtl::OUString sURL
= aURLED
.GetText();
328 sURL
= URIHelper::SmartRel2Abs(INetURLObject(), sURL
, Link(), false );
329 // #i100683# file URLs should be normalized in the UI
330 static const sal_Char
* pFile
= "file:";
331 sal_Int32 nLength
= ((sal_Int32
)sizeof(pFile
)-1);
332 if( sURL
.copy(0, nLength
).equalsAsciiL( pFile
, nLength
))
333 sURL
= URIHelper::simpleNormalizedMakeRelative(::rtl::OUString(), sURL
);
336 SwFmtINetFmt
aINetFmt(sURL
, aTargetFrmLB
.GetText());
337 aINetFmt
.SetName(aNameED
.GetText());
338 bModified
|= aURLED
.GetText() != aURLED
.GetSavedValue();
339 bModified
|= aNameED
.IsModified();
340 bModified
|= aTargetFrmLB
.GetSavedValue() != aTargetFrmLB
.GetText();
342 //zuerst die gueltigen Einstellungen setzen
343 String sEntry
= aVisitedLB
.GetSelectEntry();
344 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName( sEntry
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
345 aINetFmt
.SetVisitedFmtId(nId
);
346 aINetFmt
.SetVisitedFmt(nId
== RES_POOLCHR_INET_VISIT
? aEmptyStr
: sEntry
);
348 sEntry
= aNotVisitedLB
.GetSelectEntry();
349 nId
= SwStyleNameMapper::GetPoolIdFromUIName( sEntry
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
350 aINetFmt
.SetINetFmtId( nId
);
351 aINetFmt
.SetINetFmt(nId
== RES_POOLCHR_INET_NORMAL
? aEmptyStr
: sEntry
);
353 if( pINetItem
&& pINetItem
->GetMacroTable().Count() )
354 aINetFmt
.SetMacroTbl( &pINetItem
->GetMacroTable() );
356 if(aVisitedLB
.GetSavedValue() != aVisitedLB
.GetSelectEntryPos())
359 if(aNotVisitedLB
.GetSavedValue() != aNotVisitedLB
.GetSelectEntryPos())
362 if(aTextED
.IsModified())
365 rSet
.Put(SfxStringItem(FN_PARAM_SELECTION
, aTextED
.GetText()));
373 /*-----------------14.08.96 11.30-------------------
375 --------------------------------------------------*/
377 SfxTabPage
* SwCharURLPage::Create( Window
* pParent
,
378 const SfxItemSet
& rAttrSet
)
380 return ( new SwCharURLPage( pParent
, rAttrSet
) );
383 /*-----------------14.08.96 15.00-------------------
385 --------------------------------------------------*/
387 IMPL_LINK( SwCharURLPage
, InsertFileHdl
, PushButton
*, EMPTYARG
)
389 FileDialogHelper
aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE
, 0 );
390 if( aDlgHelper
.Execute() == ERRCODE_NONE
)
392 Reference
< XFilePicker
> xFP
= aDlgHelper
.GetFilePicker();
393 aURLED
.SetText(xFP
->getFiles().getConstArray()[0]);
397 /*-----------------14.08.96 15.00-------------------
399 --------------------------------------------------*/
401 IMPL_LINK( SwCharURLPage
, EventHdl
, PushButton
*, EMPTYARG
)
403 bModified
|= SwMacroAssignDlg::INetFmtDlg( this,
404 ::GetActiveView()->GetWrtShell(), pINetItem
);