summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmelia Wang <amwang@novell.com>2010-09-13 14:37:51 +0200
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-09-13 15:40:35 +0200
commit8fd87a90a5ebcc9d8c4ddc7ece6d20debd58e801 (patch)
tree96c24aabf9ef9aeed4af9920b4283ce2b6edba4c
parent1f578e21a92b3532ddfd8e0fd007a7ec6b2ee240 (diff)
cjk-character-units-imp.diff: add a new unit 'character unit'
-rw-r--r--sw/inc/swmodule.hxx2
-rw-r--r--sw/source/ui/app/appopt.cxx10
-rw-r--r--sw/source/ui/app/swmodul1.cxx57
-rw-r--r--sw/source/ui/config/optload.cxx17
-rw-r--r--sw/source/ui/config/usrpref.cxx11
-rw-r--r--sw/source/ui/inc/pggrid.hxx2
-rw-r--r--sw/source/ui/inc/uitool.hxx3
-rw-r--r--sw/source/ui/inc/usrpref.hxx12
-rw-r--r--sw/source/ui/misc/pggrid.cxx32
-rw-r--r--sw/source/ui/shells/textsh1.cxx4
-rw-r--r--sw/source/ui/uiview/view.cxx17
-rw-r--r--sw/source/ui/utlui/uitool.cxx13
12 files changed, 168 insertions, 12 deletions
diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index c8e601143877..77c2e56bbe6c 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -169,6 +169,8 @@ public:
//default page mode for text grid
void ApplyDefaultPageMode(sal_Bool bIsSquaredPageMode);
+ void ApplyUserCharUnit(BOOL bApplyChar, BOOL bWeb); // apply_char_unit
+
// ConfigItems erzeugen
SwModuleOptions* GetModuleConfig() { return pModuleConfig;}
SwPrintOptions* GetPrtOptions(sal_Bool bWeb);
diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx
index c6e2527ba0c8..0bc088f06a98 100644
--- a/sw/source/ui/app/appopt.cxx
+++ b/sw/source/ui/app/appopt.cxx
@@ -139,6 +139,7 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId )
FN_PARAM_WRTSHELL, FN_PARAM_WRTSHELL,
FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
SID_ATTR_METRIC, SID_ATTR_METRIC,
+ SID_ATTR_APPLYCHARUNIT, SID_ATTR_APPLYCHARUNIT,
SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
RES_BACKGROUND, RES_BACKGROUND,
SID_HTML_MODE, SID_HTML_MODE,
@@ -379,6 +380,15 @@ void SwModule::ApplyItemSet( USHORT nId, const SfxItemSet& rSet )
const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
::SetDfltMetric((FieldUnit)pMetricItem->GetValue(), !bTextDialog);
}
+
+ if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_APPLYCHARUNIT,
+ FALSE, &pItem ) )
+ {
+ SFX_APP()->SetOptions(rSet);
+ const SfxBoolItem* pCharItem = (const SfxBoolItem*)pItem;
+ ::SetApplyCharUnit(pCharItem->GetValue(), !bTextDialog);
+ }
+
if( SFX_ITEM_SET == rSet.GetItemState(FN_HSCROLL_METRIC,
FALSE, &pItem ) )
{
diff --git a/sw/source/ui/app/swmodul1.cxx b/sw/source/ui/app/swmodul1.cxx
index 2b3a5df1391b..e4b152257141 100644
--- a/sw/source/ui/app/swmodul1.cxx
+++ b/sw/source/ui/app/swmodul1.cxx
@@ -308,6 +308,63 @@ void SwModule::ApplyRulerMetric( FieldUnit eMetric, BOOL bHorizontal, BOOL bWeb
pTmpView = SwModule::GetNextView(pTmpView);
}
}
+
+/*-------------------------------------------------
+set the usrpref 's char unit attribute and set ruler
+'s unit as char if the "apply char unit" is checked
+--------------------------------------------------*/
+void SwModule::ApplyUserCharUnit(BOOL bApplyChar, BOOL bWeb)
+{
+ SwMasterUsrPref* pPref;
+ if(bWeb)
+ {
+ if(!pWebUsrPref)
+ GetUsrPref(sal_True);
+ pPref = pWebUsrPref;
+ }
+ else
+ {
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pPref = pUsrPref;
+ }
+ BOOL bOldApplyCharUnit = pPref->IsApplyCharUnit();
+ BOOL bHasChanged = FALSE;
+ if(bOldApplyCharUnit != bApplyChar)
+ {
+ pPref->SetApplyCharUnit(bApplyChar);
+ bHasChanged = TRUE;
+ }
+
+ if( !bHasChanged )
+ return;
+
+ FieldUnit eHScrollMetric = pPref->IsHScrollMetric() ? pPref->GetHScrollMetric() : pPref->GetMetric();
+ FieldUnit eVScrollMetric = pPref->IsVScrollMetric() ? pPref->GetVScrollMetric() : pPref->GetMetric();
+ if(bApplyChar)
+ {
+ eHScrollMetric = FUNIT_CHAR;
+ eVScrollMetric = FUNIT_LINE;
+ }
+ else
+ {
+ eHScrollMetric = FUNIT_CM;
+ eVScrollMetric = FUNIT_CM;
+ }
+ SwView* pTmpView = SwModule::GetFirstView();
+ // fuer alle MDI-Fenster das Lineal umschalten
+ while(pTmpView)
+ {
+ if(bWeb == (0 != PTR_CAST(SwWebView, pTmpView)))
+ {
+ pTmpView->ChangeVLinealMetric(eVScrollMetric);
+ pTmpView->ChangeTabMetric(eHScrollMetric);
+ }
+
+ pTmpView = SwModule::GetNextView(pTmpView);
+ }
+}
+
/*-----------------13.11.96 11.57-------------------
--------------------------------------------------*/
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index 4a0c9c2a6b25..1319cbfdabe8 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -220,6 +220,12 @@ BOOL __EXPORT SwLoadOptPage::FillItemSet( SfxItemSet& rSet )
bRet = TRUE;
}
+ if(aUseCharUnit.IsChecked() != aUseCharUnit.GetSavedValue())
+ {
+ rSet.Put(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, aUseCharUnit.IsChecked()));
+ bRet = TRUE;
+ }
+
sal_Bool bIsSquaredPageModeFlag = aUseSquaredPageMode.IsChecked();
if ( bIsSquaredPageModeFlag != aUseSquaredPageMode.GetSavedValue() )
{
@@ -306,6 +312,17 @@ void __EXPORT SwLoadOptPage::Reset( const SfxItemSet& rSet)
aUseSquaredPageMode.Check( bSquaredPageMode );
aUseSquaredPageMode.SaveValue();
}
+
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_APPLYCHARUNIT, FALSE, &pItem))
+ {
+ BOOL bUseCharUnit = ((const SfxBoolItem*)pItem)->GetValue();
+ aUseCharUnit.Check(bUseCharUnit);
+ }
+ else
+ {
+ aUseCharUnit.Check(pUsrPref->IsApplyCharUnit());
+ }
+ aUseCharUnit.SaveValue();
}
/*-----------------13.01.97 14.44-------------------
Metric des Deftabstops umschalten
diff --git a/sw/source/ui/config/usrpref.cxx b/sw/source/ui/config/usrpref.cxx
index 85d3886fc79f..013e7dcfaa94 100644
--- a/sw/source/ui/config/usrpref.cxx
+++ b/sw/source/ui/config/usrpref.cxx
@@ -263,9 +263,10 @@ Sequence<OUString> SwLayoutViewConfig::GetPropertyNames()
"Window/IsVerticalRulerRight", //15
"ViewLayout/Columns", //16
"ViewLayout/BookMode", //17
- "Other/IsSquaredPageMode" //18
+ "Other/IsSquaredPageMode", //18
+ "Other/ApplyCharUnit" //19
};
- const int nCount = bWeb ? 14 : 19;
+ const int nCount = bWeb ? 14 : 20;
Sequence<OUString> aNames(nCount);
OUString* pNames = aNames.getArray();
for(int i = 0; i < nCount; i++)
@@ -332,8 +333,9 @@ void SwLayoutViewConfig::Commit()
case 16: pValues[nProp] <<= (sal_Int32)rParent.GetViewLayoutColumns(); break;// "ViewLayout/Columns",
case 17: bSet = rParent.IsViewLayoutBookMode(); break;// "ViewLayout/BookMode",
case 18: bSet = rParent.IsSquaredPageMode(); break;// "Other/IsSquaredPageMode",
+ case 19: bSet = rParent.IsApplyCharUnit(); break;// "Other/IsApplyCharUnit",
}
- if(nProp < 8 || nProp == 10 || nProp == 15 || nProp == 17 || nProp == 18 )
+ if(nProp < 8 || nProp == 10 || nProp == 15 || nProp == 17 || nProp == 18 || nProp == 19 )
pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
}
PutProperties(aNames, aValues);
@@ -353,7 +355,7 @@ void SwLayoutViewConfig::Load()
{
if(pValues[nProp].hasValue())
{
- sal_Bool bSet = nProp < 8 || nProp == 10 || nProp == 17 || nProp == 18 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
+ sal_Bool bSet = nProp < 8 || nProp == 10 || nProp == 17 || nProp == 18 || nProp == 19 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
switch(nProp)
{
case 0: rParent.SetCrossHair(bSet); break;// "Line/Guide",
@@ -419,6 +421,7 @@ void SwLayoutViewConfig::Load()
break;// "ViewLayout/Columns",
case 17: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
case 18: rParent.SetDefaultPageMode(bSet,TRUE); break;// "Other/IsSquaredPageMode",
+ case 19: rParent.SetApplyCharUnit(bSet); break;// "Other/ApplyUserChar"
}
}
}
diff --git a/sw/source/ui/inc/pggrid.hxx b/sw/source/ui/inc/pggrid.hxx
index 92ba2fa2ebd4..ef8355846a30 100644
--- a/sw/source/ui/inc/pggrid.hxx
+++ b/sw/source/ui/inc/pggrid.hxx
@@ -76,7 +76,7 @@ class SwTextGridPage: public SfxTabPage
FixedText aColorFT;
ColorListBox aColorLB;
- Window* aControls[18];
+ Window* aControls[20];
sal_Int32 m_nRubyUserValue;
sal_Bool m_bRubyUserValue;
diff --git a/sw/source/ui/inc/uitool.hxx b/sw/source/ui/inc/uitool.hxx
index e48f78f9aa96..aea135da9361 100644
--- a/sw/source/ui/inc/uitool.hxx
+++ b/sw/source/ui/inc/uitool.hxx
@@ -73,6 +73,9 @@ void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet );
SW_DLLPUBLIC FieldUnit GetDfltMetric(BOOL bWeb);
void SetDfltMetric(FieldUnit eMetric, BOOL bWeb);
+SW_DLLPUBLIC BOOL HasCharUnit( BOOL bWeb );
+void SetApplyCharUnit(BOOL bApplyChar, BOOL bWeb);
+
// ListBox mit allen Zeichenvorlagen fuellen - ausser Standard!
SW_DLLPUBLIC void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, BOOL bSorted = FALSE, BOOL bWithDefault = FALSE);
diff --git a/sw/source/ui/inc/usrpref.hxx b/sw/source/ui/inc/usrpref.hxx
index 7864bf135934..7331471fb4d9 100644
--- a/sw/source/ui/inc/usrpref.hxx
+++ b/sw/source/ui/inc/usrpref.hxx
@@ -153,6 +153,7 @@ class SwMasterUsrPref : public SwViewOption
SwCursorConfig aCursorConfig;
SwWebColorConfig* pWebColorConfig;
+ sal_Bool bApplyCharUnit; // apply_char_unit
public:
SwMasterUsrPref(BOOL bWeb);
~SwMasterUsrPref();
@@ -254,6 +255,17 @@ public:
aLayoutConfig.SetModified();
}
+ sal_Bool IsApplyCharUnit() const
+ {
+ return bApplyCharUnit;
+ }
+ void SetApplyCharUnit(BOOL bSet, sal_Bool bNoModify = sal_False)
+ {
+ bApplyCharUnit = bSet;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
sal_Int32 GetDefTab() const { return nDefTab;}
void SetDefTab( sal_Int32 nSet, sal_Bool bNoModify = sal_False )
{
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index a6e20cc56dc3..777479198157 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -113,7 +113,9 @@ SwTextGridPage::SwTextGridPage(Window *pParent, const SfxItemSet &rSet) :
aControls[14] =&aPrintCB;
aControls[15] =&aColorFT;
aControls[16] =&aColorLB;
- aControls[17] =0;
+ aControls[17] =&aLinesRangeFT;
+ aControls[18] =&aCharsRangeFT;
+ aControls[19] =0;
Link aLink = LINK(this, SwTextGridPage, CharorLineChangedHdl);
aCharsPerLineNF.SetUpHdl(aLink);
@@ -309,6 +311,10 @@ void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
aGridItem.SetPrintGrid(aPrintCB.IsChecked());
aGridItem.SetColor(aColorLB.GetSelectEntryColor());
rSet.Put(aGridItem);
+/// Amelia
+ SwView * pView = ::GetActiveView();
+ pView->GetHLineal().SetCharWidth((long)(aCharWidthMF.GetValue(FUNIT_TWIP)/56.7));
+ pView->GetVLineal().SetLineHeight((long)(aTextSizeMF.GetValue(FUNIT_TWIP)/56.7));
}
/* -----------------------------08.02.2002 10:54------------------------------
@@ -413,6 +419,10 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField*, pField)
long nHeight = static_cast< sal_Int32 >(m_aPageSize.Height() / aLinesPerPageNF.GetValue());
aTextSizeMF.SetValue(aTextSizeMF.Normalize(nHeight), FUNIT_TWIP);
aRubySizeMF.SetValue(0, FUNIT_TWIP);
+ String aMaxLinesFTStr = String::CreateFromAscii("( 1 - ");
+ aMaxLinesFTStr += String::CreateFromInt32(aLinesPerPageNF.GetValue());
+ aMaxLinesFTStr += String::CreateFromAscii(" )");
+ aLinesRangeFT.SetText( aMaxLinesFTStr );
m_nRubyUserValue = nHeight;
m_bRubyUserValue = sal_True;
@@ -421,6 +431,10 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField*, pField)
{
long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / aCharsPerLineNF.GetValue());
aCharWidthMF.SetValue(aCharWidthMF.Normalize(nWidth), FUNIT_TWIP);
+ String aMaxCharsFTStr = String::CreateFromAscii("( 1 - ");
+ aMaxCharsFTStr += String::CreateFromInt32(aCharsPerLineNF.GetValue());
+ aMaxCharsFTStr += String::CreateFromAscii(" )");
+ aCharsRangeFT.SetText( aMaxCharsFTStr );
}
}
GridModifyHdl(0);
@@ -436,7 +450,6 @@ IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, SpinField*, pField)
if (&aTextSizeMF == pField)
{
sal_Int32 nTextSize = static_cast< sal_Int32 >(aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
- aCharsPerLineNF.SetValue(m_aPageSize.Width() / nTextSize);
m_bRubyUserValue = sal_False;
}
//set maximum line per page
@@ -454,14 +467,22 @@ IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, SpinField*, pField)
sal_Int32 nTextSize = static_cast< sal_Int32 >(aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
aLinesPerPageNF.SetValue(m_aPageSize.Height() / nTextSize);
m_bRubyUserValue = sal_False;
+ String aRangesStr = String::CreateFromAscii("( 1 - ");
+ aRangesStr += String::CreateFromInt32( m_aPageSize.Height() / nTextSize );
+ aRangesStr += String::CreateFromAscii(" )");
+ aLinesRangeFT.SetText( aRangesStr );
}
else if (&aCharWidthMF == pField)
{
sal_Int32 nTextWidth = static_cast< sal_Int32 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP)));
+ sal_Int32 nMaxChar = 45 ;
if (nTextWidth)
- aCharsPerLineNF.SetValue(m_aPageSize.Width() / nTextWidth);
- else
- aCharsPerLineNF.SetValue( 45 );
+ nMaxChar = m_aPageSize.Width() / nTextWidth;
+ aCharsPerLineNF.SetValue( nMaxChar );
+ String aCharRangeStr = String::CreateFromAscii("( 1 - ");
+ aCharRangeStr += String::CreateFromInt32( nMaxChar );
+ aCharRangeStr += String::CreateFromAscii(" )");
+ aCharsRangeFT.SetText( aCharRangeStr );
}
//rubySize is disabled
}
@@ -489,6 +510,7 @@ IMPL_LINK(SwTextGridPage, GridTypeHdl, RadioButton*, pButton)
{
aCharsPerLineFT.Enable(sal_False);
aCharsPerLineNF.Enable(sal_False);
+ aCharsRangeFT.Enable(sal_False);
aCharWidthFT.Enable(sal_False);
aCharWidthMF.Enable(sal_False);
}
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index e7d7ef613f2b..b13aaed44ee2 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -877,6 +877,10 @@ void SwTextShell::Execute(SfxRequest &rReq)
{
FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)));
+
+ BOOL bApplyCharUnit = ::HasCharUnit(0 != PTR_CAST(SwWebView, &GetView()));
+ SW_MOD()->PutItem(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, bApplyCharUnit));
+
SfxItemSet aCoreSet( GetPool(),
RES_PARATR_BEGIN, RES_PARATR_END - 1,
// --> OD 2008-02-25 #refactorlists#
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index 4396ff03807c..3579cdc952f6 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -117,6 +117,7 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -950,9 +951,21 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
pVRuler->SetZoom( aZoomFract );
pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
FieldUnit eMetric = pUsrPref->GetHScrollMetric();
- pHRuler->SetUnit( eMetric );
+
+ BOOL bApplyCharUnit = pUsrPref->IsApplyCharUnit();
+ if ( bApplyCharUnit )
+ pHRuler->SetUnit( FUNIT_CHAR );
+ else
+ pHRuler->SetUnit( eMetric );
+
eMetric = pUsrPref->GetVScrollMetric();
- pVRuler->SetUnit( eMetric );
+ if ( bApplyCharUnit )
+ pVRuler->SetUnit(FUNIT_LINE);
+ else
+ pVRuler->SetUnit( eMetric );
+
+ pHRuler->SetCharWidth( 371 ); // default character width
+ pVRuler->SetLineHeight( 551 ); // default line height
// DocShell setzen
pDocSh->SetView( this );
diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx
index 01f6c4e84d7a..b9982cc78227 100644
--- a/sw/source/ui/utlui/uitool.cxx
+++ b/sw/source/ui/utlui/uitool.cxx
@@ -736,6 +736,19 @@ String GetAppLangDateTimeString( const DateTime& rDT )
return sRet;
}
+/*----------------------------------------------------------------------------
+ * add a new function which can get and set the current "SID_ATTR_APPLYCHARUNIT" value
+ *---------------------------------------------------------------------------*/
+BOOL HasCharUnit( BOOL bWeb)
+{
+ return SW_MOD()->GetUsrPref(bWeb)->IsApplyCharUnit();
+}
+
+void SetApplyCharUnit(BOOL bApplyChar, BOOL bWeb)
+{
+ SW_MOD()->ApplyUserCharUnit(bApplyChar, bWeb);
+}
+
/*-- 26.01.2006 08:06:33---------------------------------------------------
-----------------------------------------------------------------------*/